# Ch 2 Ex 4: This program calculates the subtotal of 5 items. # A 6% sales tax is added to the subtotal to produce the total purchase. # Written by Greg Lamb. # Last modified on 04/01/2015 # Get prices for items purchased Item1=raw_input("Enter First Item Price ") print(Item1) Item2=raw_input("Enter Second Item Price ") print(Item2) Item3=raw_input("Enter Third Item Price ") print(Item3) Item4=raw_input("Enter Fourth Item Price ") print(Item4) Item5=raw_input("Enter Fifth Item Price ") print(Item5) # Calculate Subtotal print("Subtotal") Subtotal=float(Item1)+float(Item2)+float(Item3)+float(Item4)+float(Item5) print(Subtotal) # Calculate Sales Tax at 6% print("Sales Tax") SalesTax=float(Subtotal) * 0.06 print(SalesTax) # Calculate Total print("Total") Total=float(Subtotal) + float(SalesTax) # Display result in dollars and cents print(Total)
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