# Programming Exercises #4. Total Purchase # written by Tuan Nguyen # Declare and assign variable Tax Tax=.06 # Ask the user for the price of each of the five items and assigning it to a variable FirstItem = input("What is the price of the first item?") SecondItem = input("What is the price of the second item?") ThirdItem = input("What is the price of the third item?") FourthItem = input("What is the price of the fourth item?") FifthItem = input("What is the price of the fifth item?") # Calculate and display the subtotal amount before tax SubTotal = FirstItem + SecondItem + ThirdItem + FourthItem + FifthItem print("The subtotal is ") print(SubTotal) # Calculate and display the tax amount. TaxAmount = SubTotal * Tax print("Sales tax is ") print(TaxAmount) # Calculate and display the total amount. TotalAmount = SubTotal + TaxAmount print("Your total amount is ") print(TotalAmount)
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question