朋友们大家好,
今天我给大家带来的内容是:用python做餐厅点餐系统。列表里的内容可以进行添加或修改
上代码:
import time
import random
buy=[]
money=0
food=[['芝士三明治',6],['牛排汉堡',16],['超多薯条',13],['大杯可乐',6],['奶昔',8]]
random.shuffle(food)
number=random.randint(0,1)
print('+==========欢迎使用点餐系统==========+')
time.sleep(1)
print('今日推荐美食:',food[number][0],food[number+1][0],food[number+2][0])
print()
time.sleep(1)
print('今日美食:')
time.sleep(1.5)
for i in range(len(food)):
print(i+1,food[i][0])
time.sleep(0.1)
while True:
time.sleep(0.8)
print()
ask=int(input('请问您想选择哪个食物(序号,按999结账,按99清空购物车):'))
if ask==999:
print()
print('+==================+')
time.sleep(0.8)
if len(buy)>0:
print('您选择的食物:')
time.sleep(0.8)
for i in range(len(buy)):
print(buy[i],end='')
time.sleep(0.2)
time.sleep(0.8)
print()
print('总计金额:',money,'元')
ask3=input('您是否结账[y/n]?')
if ask3=='y':
print()
print('您已下单,感谢您的购买~')
buy.clear()
time.sleep(1)
if ask3=='n':
print('您选择继续购买')
time.sleep(0.8)
else:
print('你目前还没有买食物哦~')
time.sleep(0.8)
print('+==================+')
if ask==99:
print()
print('您已清空购物车')
buy.clear()
else:
print()
if ask==999 or ask==99:
continue
else:
if len(food)>=ask:
print('+==============================+')
print('您选择的食物:',food[ask-1][0])
time.sleep(0.6)
print('超实惠价格:',food[ask-1][1])
time.sleep(0.8)
print()
ask2=input('加入购物车[y/n]? ')
if ask2=='y':
print('好的')
buy+=[food[ask-1][0]]
money+=food[ask-1][1]
time.sleep(0.8)
print('+==============================+')
else:
print('您选择不加入购物车')
time.sleep(0.8)
print('+==============================+')
if ask>len(food):
print('你选择的',ask,'号食物不存在')
time.sleep(0.8)
print('+==============================+')
好啦,今天的内容就到这里,感谢观看,谢谢。