20193103 2019-2020-2 《Python程序设计》实验四报告
课程:《Python程序设计》 班级: 1931 姓名: 陈柏维 学号:20193103 实验教师:王志强 实验日期:2020年6月14日 必修/选修: 公选课
1.实验内容
Python综合应用:爬虫、数据处理、可视化、机器学习、神经网络、游戏、网络安全等 本次实践我选择做一个餐厅点菜程序。
2. 实验过程及结果
# coding UTF-8
# version = version_1_2
today_menu = ["今天菜单如下", "1 宫保鸡丁", "2 青椒鸡米粒", "3 白萝卜焖肉", "4 蒜薹腊肉", "5 豆腐包肉 ",
"6 鲤鱼跃龙门", "7 凉拌莲藕", "8 红烧南瓜", "9 大白菜", "10 青菜", "11 荷包蛋(另加2元)", "12 蛋炒饭(10元)"]
price = [0, 0, 12, 0, 0, 10, 13, 0, 9, 11, 14, 0, 10, 0, 15, 0]
def getTodayMenu():
return today_menu
def showTodayMenu(interable):
for today_menu_details in today_menu:
print(today_menu_details)
def showCombineNote():
print("提示:一荤一素10,两素菜9元,一荤两素11,,三素菜10,两荤菜12,两荤一素13,两荤两素14,两荤三素15元")
print("请输入您点餐的编号,编号之间用逗号分开,不同份数之间用空格隔开
例如输入1,9,10 2,6,8 3,10,谢谢 : ")
def dealWithUserInput():
user_choise = input()
user_choise_list = user_choise.split()
price_total = 0
price_one = 0
choosed_list = []
pay_total = 0
for one_order in user_choise_list:
count_i = count_j = 0
hebaodan = 0
danchaofan = 0
one_order_list = one_order.split(",")
for menu_item in one_order_list:
if menu_item.strip().isdigit():
if int(menu_item.strip()) < 7:
count_j += 1
elif int(menu_item.strip()) < 11:
count_i += 1
elif int(menu_item.strip()) == 11:
hebaodan += 1
elif int(menu_item.strip()) == 12:
danchaofan += 1
choosed_list.append(int(menu_item))
else:
print("您输入的有非数字类型,请重新运行程序,谢谢")
exit()
choosed_list.append(0)
if price[count_i * 4 + count_j] == 0 and "12" not in one_order:
print("您输入的不是一个正确的组合,请重新运行程序, 谢谢")
exit()
else:
price_one = price[count_i * 4 + count_j] + hebaodan * 2 + danchaofan * 10
price_total += price_one
if price_total >= 30:
pay_total = price_total - 4