VAT Calculator
Write a program that asks the user for the name of an item they have bought and the price the item was bought for. The program should then calculate how much tax was paid on the item. The name of the item, the bought for price and the tax paid should then be displayed to the user.
Enter the name of an item you've bought: Laptop How much did it cost: £ 400 You bought a Laptop for £400. You paid £80 in tax.
get name of item from user get price of item from user calculate tax by multiplying the price of item by 0.2 print the output using all three variables
name_of_item = str(input("Enter the name of an item you've bought: "))
price_of_item = int(input("How much did it cost: £ "))
tax_paid = price_of_item * 0.2
print("You bought a", name_of_item, "for £", price_of_item, ".")
print("You paid £", tax_paid, "in tax.")
# Get the name of item and price of item from the user
name_of_item = str(input("Enter the name of an item you've bought: "))
price_of_item = int(input("How much did it cost: £ "))
# Calculate the tax paid
tax_paid = price_of_item * 0.2
# Display the required outputs
print("You bought a", name_of_item, "for £", price_of_item, ".")
print("You paid £", tax_paid, "in tax.")
Extension
Add another item to the program, calculate how much the user spent in total, and display all of the information back to the user.
Enter the name of an item you've bought: Laptop How much did it cost: £ 400 Enter the name of another item you've bought: Laptop Bag How much did it cost: £ 50 You bought a Laptop for £400. You bought a Laptop bag for £50. You spent £450 in total. You paid £90 in tax.