Mar-25-2017, 10:03 AM
print ("This is a tax calculator. Enter in the price and your item\n" "and the program will calculate how much it costs with tax.""") #Create tax function that takes price and tax_rate as imputs and returns the total price def calculate_tax(price, start, end, increment): for n in range(start, end, increment): tax_rate = n * .01 tax = price * tax_rate total = round((price + tax), 2) yield n, tax, tax_rate, total #float is a variable type for decimals item = str(input("Please enter an item: ")) my_price = float(input("Price of the item $")) for n, tax, tax_rate, total in calculate_tax(my_price, 5, 26, 5): print('{}% tax on a {} costing ${:.2f} is ${:.2f} for a total of ${:.2f}' .format(n, item, my_price, tax, total))test:
Output:This is a tax calculator. Enter in the price and your item
and the program will calculate how much it costs with tax.
Please enter an item: Chocolate Cake
Price of the item $17.5
5% tax on a Chocolate Cake costing $17.50 is $0.88 for a total of $18.38
10% tax on a Chocolate Cake costing $17.50 is $1.75 for a total of $19.25
15% tax on a Chocolate Cake costing $17.50 is $2.62 for a total of $20.12
20% tax on a Chocolate Cake costing $17.50 is $3.50 for a total of $21.00
25% tax on a Chocolate Cake costing $17.50 is $4.38 for a total of $21.88