快餐点餐

Posted skyqq

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了快餐点餐相关的知识,希望对你有一定的参考价值。

不涉及函数应用

技术分享图片
 1 Food_list = {
 2     pizza: [cheese, onion, green_papper, mushroom],
 3     hamburger: [beef, pork, chicken, lettuce, tomato, cheese, onion, cucumber],
 4     pasta: [fish, beef, onion, basil, meatball, black_papper],
 5     fried_chicken: [leg, wings, breast, chili, papper],
 6     ice_cream: [vanilla, Chocolate, strawbarry, banana],
 7     french_fries: [small_portion, medium, large_portion],
 8     cake: [cream, chocolate, mango, toon],
 9     drinks: [cola, sprite, coffee, milkshake]
10     }
11 # print menu
12 for key in Food_list.keys():
13     print(key.title())
14 choice = input(Please choose you favorite food:
)
15 
16 Food_select = {
17     pizza: [],
18     hamburger: [],
19     pasta: [],
20     fried_chicken: [],
21     ice_cream: [],
22     french_fries: [],
23     cake: [],
24     drinks: []
25     }
26 Drop_out = True
27 # Enter a list according to the user
28 while Drop_out:
29     if choice.isalpha():
30         if choice == q:
31             for key in list(Food_select.keys()):
32                 if not Food_select.get(key):
33                     del Food_select[key]
34             print(Food_select)
35             Drop_out = False
36             break
37         elif choice == b:
38             print(You have returned to the top)
39         else:
40             # choice = choice.title()
41             print(Food_list[choice])
42             choice2 = input(
43                 Please choose the ingredients you like:
Drop out:q
Return to superior:b
)
44             if choice2.isalpha():
45                 if choice2 == "q":
46                     for key in list(Food_select.keys()):
47                         if not Food_select.get(key):
48                             del Food_select[key]
49                     print(Food_select)
50                     Drop_out = False
51                     break
52                 elif choice2 == "b":
53                     for key in Food_list.keys():
54                         print(key)
55                     choice = input(Please choose you favorite food:
)
56                 else:
57                     while choice2 in Food_list[choice]:
58                         Food_select[choice].append(choice2)
59                         print(Food_select[choice])
60                                                 
61                         if choice2 not in Food_list[choice]:
62                             print(Please select according to the ingredient list!)
63                         break
64             else:
65                 print(Please follow the menu order!)
66 
67     else:
68         print(Please follow the menu order!)
View Code

 

Food_list = {
‘pizza‘: [‘cheese‘, ‘onion‘, ‘green_papper‘, ‘mushroom‘],
‘hamburger‘: [‘beef‘, ‘pork‘, ‘chicken‘, ‘lettuce‘, ‘tomato‘, ‘cheese‘, ‘onion‘, ‘cucumber‘],
‘pasta‘: [‘fish‘, ‘beef‘, ‘onion‘, ‘basil‘, ‘meatball‘, ‘black_papper‘],
‘fried_chicken‘: [‘leg‘, ‘wings‘, ‘breast‘, ‘chili‘, ‘papper‘],
‘ice_cream‘: [‘vanilla‘, ‘Chocolate‘, ‘strawbarry‘, ‘banana‘],
‘french_fries‘: [‘small_portion‘, ‘medium‘, ‘large_portion‘],
‘cake‘: [‘cream‘, ‘chocolate‘, ‘mango‘, ‘toon‘],
‘drinks‘: [‘cola‘, ‘sprite‘, ‘coffee‘, ‘milkshake‘]
}
# print menu
for key in Food_list.keys():
print(key.title())
choice = input(‘Please choose you favorite food: )

Food_select = {
‘pizza‘: [],
‘hamburger‘: [],
‘pasta‘: [],
‘fried_chicken‘: [],
‘ice_cream‘: [],
‘french_fries‘: [],
‘cake‘: [],
‘drinks‘: []
}
Drop_out = True
# Enter a list according to the user
while Drop_out:
if choice.isalpha():
if choice == ‘q‘:
for key in list(Food_select.keys()):
if not Food_select.get(key):
del Food_select[key]
print(Food_select)
Drop_out = False
break
elif choice == ‘b‘:
print(‘You have returned to the top‘)
else:
# choice = choice.title()
print(Food_list[choice])
choice2 = input(
‘Please choose the ingredients you like: Drop out:q Return to superior:b )
if choice2.isalpha():
if choice2 == "q":
for key in list(Food_select.keys()):
if not Food_select.get(key):
del Food_select[key]
print(Food_select)
Drop_out = False
break
elif choice2 == "b":
for key in Food_list.keys():
print(key)
choice = input(‘Please choose you favorite food: )
else:
while choice2 in Food_list[choice]:
Food_select[choice].append(choice2)
print(Food_select[choice])
 
if choice2 not in Food_list[choice]:
print(‘Please select according to the ingredient list!‘)
break
else:
print(‘Please follow the menu order!‘)

else:
print(‘Please follow the menu order!‘)


以上是关于快餐点餐的主要内容,如果未能解决你的问题,请参考以下文章

设计模式之装饰器模式

Chrome Kiosk Mode All In One

消息队列MQ是啥玩意

生产者和消费者模式--java设计模式

微信小程序的网上订餐点餐系统vue_uniapp

片段中的Android Snackbar NullPointerException