# Explain the purpose of the program to the user. # Prompt user for description of three items. # Prompt user for the quantity of each item. # Prompt user for the price of each item. # Prompt user for the weight (in lbs.) of each item. # Multiply the price of each item by its quantity. # Combine the prices of all items for the subtotal. # Multiply weight of each item type by its quantity. # Calculate shipping and handling: combine weight of all items and multiply by $0.25; add $5 handling. # Calculate tax: combine subtotal and shipping & handling costs; tax (multiply by) 8.5% ($0.085). # Calculate total: combine subtotal, S&H, and tax. # Print items purchased. # Print subtotal. # Print shipping and handling costs. # Print tax. # Print total costs. def delivery(): print ("This program will calculate the cost of three items, shipping and handling, tax, and total.") shipping = 0 subtotal = 0 freight = 0 item = ["","",""] for i in range (3): item[i] =(input("Please list an item you purchased: ")) quantity = eval(input("How many did you purchase? ")) price = eval(input("What was the price of each? $")) weight = eval(input("What was the weight (in lbs.) of each? ")) price = price * quantity subtotal = subtotal + price ship = quantity * weight shipping = shipping + ship weight = weight + freight shipping = (shipping * .25) + 5 tax = (subtotal + shipping) * .085 total = subtotal + shipping + tax print ("You have purchased: ", item[0], ",", item[1], "and", item[2], ".") print ("The subtotal is $", subtotal,".") print ("The shipping and handling costs are $", shipping,".") print ("The tax is $", tax,".") print ("The total is $", total,".") delivery() # I just need to find how to round my answers to the hundredths place, and create placeholders for my three item variables
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