Jan-26-2018, 06:20 PM
Hello so I am new to python, I only have experience in C#. This is on my assignment's I'm working on and I'm very confused. I am suppose to make it so when people use this program its like an order system for apples, cabbage, and bananas. I have to figure out how to make it so when they start it they are asked to input an item they would like so if they type apple it'll say okay how many and this is the price and then give me a total for that then move on to bananas, cabbages etc. I'm having trouble because I can't figure out how to use the item_total variable to give me the line total for each item to then give me the order_total at the bottom. Here is the code I've written so far, zero errors but not want I want to display I guess. Thanks!
#Define variables item_total = float(0) order_total = float(0) #Welcome print("Hello welcome to the store") # Input item1_apple = str("apple") item1_qty = int(input("please enter number of apples = ")) item1_price = float(0.6) item2_banana = str("banana") item2_qty = int(input("please enter number of bananas = ")) item2_price = float(1.5) item3_cabbage = str("cabbage") item3_qty = int(input("please enter number of cabbage = ")) item3_price = int(3) # process item_total = (item1_apple + item2_banana + item3_cabbage) apple_total = (item1_qty * item1_price) banana_total = (item2_qty * item2_price) cabbage_total = (item3_qty * item3_price) order_total = apple_total + banana_total + cabbage_total order_total = 'Order total: $'+str(order_total) print() print('-' * 30) print("order total for {} are {}" .format,(order_total)) print('-' * 30)