Home > other > How to write an order program in Python
How to write an order program in Python
Time:10-04
Need the program to show the menu, but some more, can reduce the number of can calculate the price,
CodePudding user response:
https://github.com/SammyLiang97/sdining can take a look at this django
CodePudding user response:
Said this?
# coding=utf-8
Menu_list=[' sweet and sour pork ribs', 'sweet and sour fish', 'big chicken', 'braise in soy sauce meat', 'mei food braised pork] Goods={' sweet and sour pork ribs' : 34, 'big chicken: 35, "braise in soy sauce meat" : 65,' the plum food braised pork: 66, 'sweet and sour fish: 54} A={} Order_list=[]
Working for v, k in goods. The items () : Print (v, k)
While True: Print (menu_list) Print (" ' 1. Order 2. Cancel the order 3. Check out "') Server=int (input (' please select service:)) If the server==1: # order While True: Menu_add=input (" please enter the name or input end of the order: Y ') If menu_add. Upper ()! :='Y' Order_list. Append (menu_add) Print (' already bought dishes: {} '. The format (order_list)) The else: Break
If the server==2: # to cancel order Menu_del=input (' please enter to cancel dishes:) Order_list. Remove (menu_del)
If the server==3: # check function Total_price=0 "" "working for v, k in goods. The items () : Print (v, k) ", " "For the item in order_list: Print (' {}, {}. The format (item, goods (item))) Total_price +=goods (item) Print (' please pay ') Print (total_price) Break The else: Print (' output error, please enter the number ')