-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMarket_Basket.py
More file actions
31 lines (25 loc) · 809 Bytes
/
Market_Basket.py
File metadata and controls
31 lines (25 loc) · 809 Bytes
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
# Here are the items in the customer's basket. Each item is a tuple
# of (item name, weight, price per pound).
#
basket = [
("Peaches", 3.0, 2.99),
("Pears", 5.0, 1.66),
("Plums", 2.5, 3.99),
]
# Calculate the total price for each item (weight times price per pound)
# and add them up to get a subtotal.
#
subtotal = 0.00
for item in basket:
fruit, weight, unit_price = item
subtotal += (weight * unit_price)
# Now calculate the sales tax and total bill.
#
tax_rate = 0.06625 # 6.625% sales tax in New Jersey
tax_amt = subtotal * tax_rate
total = subtotal + tax_amt
# Print the receipt for the customer.
#
print("Subtotal: ${:10,.2f}".format(subtotal))
print("Sales Tax: ${:10,.2f}".format(tax_amt))
print("Total: ${:10,.2f}".format(total))