-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPython_Calculate_Receipt
76 lines (65 loc) · 2.39 KB
/
Python_Calculate_Receipt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
###Ask customer for 3 items description-quantity-weight-cost.
#Return display: descriptions-quantity-weight-tax-subtotal-shipping/handling-total
###Lists###
listofdescrps=[]
listofcosts=[]
listofquants=[]
listofweights=[]
###Functions###
def getinfo():
for i in range(3):
if i==0:
descrip=input("what'd you get? ")
listofdescrps.append(descrip)
quant=int(input("How many did you get? "))
listofquants.append(quant)
price=(float(input("How much was it? "))) * quant
listofcosts.append(price)
weight=(float(input("How much does each one weigh? "))) * quant
listofweights.append(weight)
else:
descrip=input("what else did you get? ")
listofdescrps.append(descrip)
quant=int(input("How many did you get? "))
listofquants.append(quant)
price=(float(input("How much was it? "))) * quant
listofcosts.append(price)
weight=(float(input("How much does each one weigh? "))) * quant
listofweights.append(weight)
def calculatesubtotal():
subtotal=0
for i in listofcosts:
subtotal=subtotal + i
return subtotal
def calculatetax(calculatesubtotal):
tax = calculatesubtotal() * .09
return tax
def totalquant():
totquant = 0
for i in listofquants:
totquant = totquant + i
return totquant
def calculateweight():
weight=0
for i in listofweights:
weight=weight+i
return weight
def calculateshiphand(calculateweight):
handling = int(5)
shipping = calculateweight() * .25
totalsh= handling + shipping
return totalsh
def calculatetotal(calculatesubtotal,calculatetax,calculateshiphand):
totalcost = calculatesubtotal() + calculatetax(calculatesubtotal) + calculateshiphand(calculateweight)
return totalcost
def printreceipt():
getinfo()
print("Your got these items: ",', '.join(listofdescrps))
print("For a total of",totalquant(),"items.")
print("Their total weight is: ",calculateweight())
print("Subtotal for this order is: $",calculatesubtotal())
print("Tax for this order is: $",calculatetax(calculatesubtotal))
print("Shipping and handling for this order is: $",calculateshiphand(calculateweight))
print("Your total cost is: $",calculatetotal(calculatesubtotal,calculatetax,calculateshiphand))
###Calls###
printreceipt()