#------------------------------------------------------------------------------- # Name: Lunch menu: Python folio task 3 # Purpose: To take oreders # # Author: Sam Bourke # # Created: 28/08/2014 # Copyright: (c) SamBourke 2014 #------------------------------------------------------------------------------- #Here are your comments Mr parlas! pie = 2.75 pizza = 2.50 taco = 1.75 chicken_nuggets = 0.50 nachos = 4.50 wedges = 4.50 hot_dogs = 3.50 dim_sims = 1.00 cheese_burger = 3.50 beef_burger = 3.50 sausage_rolls = 3.50 #Extras sauce = 0.20 guacamole = 0.30 jalapenos = 0.50 #Drinks pump = 3.50 flavoured_water = 4.00 powerade = 4.00 coke = 4.00 BigM = 2.50 Up_n_go = 2.50 print("Menu:") #menu print print("Pie = $2.75") print("Pizza = $2.50") print("Taco = $1.75") print("Chicken nuggets = $0.50") print("Nachos = $4.50") print("Wedges = $4.50") print("Hot dogs = $3.50") print("Dim sims = $1.00") print("Cheese burger = $3.50") print("Beef burger = $3.50") print("Sausage rolls = $3.50") print("-----------------") print("Extras:") #extras print print("Sauce = $0.20") print("Guacamole = $0.30") print("Jalapenos = $0.50") print("-----------------") print("Drinks") print("pump = $3.50") print("flavoured_water = $4.00") print("powerade = $4.00") print("coke = $4.00") print("Big M = $2.50") print("Up n go = $2.50") print("-----------------") g = input("Hello, what's your name? ") g = g.title() print("Hi,", g) z = 0 #open loop cost = 0 #Start loop while z != 1: #give loop parameters a = input("Please enter your items: ") a = a.lower() o = a a = a.split() if "taco" in o: #Give if statements including loop end z = 1 if "pie" in o: z = 1 if "pizza" in o: z = 1 if "chicken nuggets" in o: z = 1 if "nachos" in o: z = 1 if "wedges" in o: z = 1 if "hot dogs" in o: z = 1 if "dim sims" in o: z = 1 if "cheese burger" in o: z = 1 if "beef burger" in o: z = 1 if "sausage rolls" in o: z = 1 if z != 1: print("An item you have entered is not on the menu") print("Please type the item you want exactly.") print("") if "sauce" in a: #Same for extras print("Sauce is in the extras menu. Please wait for extras prompt") print("") if "guacamole" in a: print("guacamole is in the extras menu. Please wait for extras prompt") print("") if "jalapenos" in a: print("jalapenos is in the extras menu. Please wait for extras prompt.") print("") if "pie" in o: #mathematics for cost until next # cost = pie b = int(input("how many pies do you want? ")) if b > 2: cost = (b * pie) if "pizza" in o: b = int(input("How many slices of pizza do you want? ")) cost = cost + (b * pizza) if "taco" in o: b = int(input("How many tacos do you want? ")) cost = cost + (b * taco) if "chicken nuggets" in o: b = int(input("How many chicken nuggets do you want? ")) cost = cost + (b * chicken_nuggets) if "nachos" in o: b = int(input("How many nachos do you want? ")) cost = cost + (b * nachos) if "wedges" in o: b = int(input("How many wedges do you want? ")) cost = cost + (b * wedges) if "hot dogs" in o: b = int(input("How many hot dogs do you want? ")) cost = cost + (b * hot_dogs) if "dim sims" in o: b = int(input("How many dim sims do you want? ")) cost = cost + (b * dim_sims) if "cheese burger" in o: b = int(input("How many cheese burgers do you want? ")) cost = cost + (b * cheese_burger) if "beef burger" in o: b = int(input("How many beef burgers do you want? ")) cost = cost + (b * beef_burger) if "sausage rolls" in o: b = int(input("How many sausage rolls do you want? ")) cost = cost + (b * sausage_rolls) if "sauce" in o: print("So getting back to the extras, which ones did you want? ") c = "y" or "Y" elif "guacamole" in o: print("So getting back to the extras, which ones did you want? ") elif "jalapenos" in o: print("So getting back to the extras, which ones did you want? ") else: c = input("Do you want any extras? (y = yes, n = no) ") #Mathematics for cost end c = c.lower() if c == "n": z = 1 if c == "y": z = 0 while z != 1: #second loop for extras menu d = input("Please enter your extras: ") d = d.lower() d = d.split() if "sauce" in d: q = int(input("how many packets of sauce do you want? ")) cost = cost + sauce * q z = 1 if "guacamole" in d: q = int(input("how much guacamole do you want? ")) cost = cost + guacamole * q z = 1 if "jalapeno" in d: q = int(input("how many servings of jalapenos do you want? ")) cost = cost + jalapeno * q z = 1 if z != 1: print("An item you have entered is not on the extras menu") print("Please type the item you want exactly.") print("") c = input("Do you want any drinks? (y = yes, n = no) ") c = c.lower() if c == "n": z = 1 if c == "y": z = 0 while z != 1: d = input("Which drinks would you like? ") d = d.lower() if "pump" in d: b = int(input("How many pumps do you want? ")) cost = cost + (b * pump) z = 1 if "flavoured water" in d: XX = input("What flavour of water do you want? ") b = int(input("How many flavoured waters do you want? ")) cost = cost + (b * flavoured_water) z = 1 if "powerade" in d: b = int(input("How many powerades do you want? ")) XX = input("What flavour of powerade do you want? ") cost = cost + (b * powerade) z = 1 if "coke" in d: b = int(input("How many cokes do you want? ")) XX = input("Do you want vanilla? (y = yes, n = no) ") cost = cost + (b * coke) z = 1 if "Big M" in d: XX = input("What flavour of Big M do you want? ") b = int(input("How many Big M's do you want? ")) cost = cost + (b * bigM) z = 1 if "up n go" in d: XX = input("What flavour of up n go do you want? ") b = int(input("How many up n go's do you want? ")) cost = cost + (b * up_n_go) z = 1 cost = ("%.2f" % (cost)) cost = str(cost) print("your total cost is:", "$" + cost) #Final cost
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