栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

《python编程快速上手——让繁琐工作自动化》8.6.1 三明治机

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

《python编程快速上手——让繁琐工作自动化》8.6.1 三明治机

import pyinputplus as pyip
# Price dictionary
bread_dict = {'wheat':12, 'white':10, 'sourdough':11}
protein_dict = {'chicken': 25, 'turkey': 29, 'ham': 20, 'tofu': 10}
cheese_dict = {'cheddar': 18, 'Swiss': 16, 'mozzarella': 15}

bread_response = pyip.inputMenu(['wheat', 'white', 'sourdough'],
                                 'Bread type: n', numbered = True)
protein_response = pyip.inputMenu(['chicken', 'turkey', 'ham', 'tofu'],
                                   'Protein type: n',numbered = True)

cheese_response = pyip.inputYesNo('Cheese? y/n: n')
if cheese_response == 'yes':
    cheese_type = pyip.inputMenu(['cheddar', 'Swiss', 'mozzarella'],
                                  'Cheese type: n',
                                  numbered = True )
    sandwich_response = pyip.inputInt('How many sandwiches do you want?n',
                                      min=1)
    total_price = sandwich_response *(bread_dict[bread_response] +
                                      protein_dict[protein_response]+
                                      cheese_dict[cheese_type])
else:
    sandwich_response = pyip.inputInt('How many sandwiches do you want?n',
                                      min=1)
    total_price = sandwich_response *(bread_dict[bread_response] +
                                      protein_dict[protein_response])

other_response = pyip.inputYesNo('Need mayo/mustard/lettuce/tomatto? n')



print('Total price is', total_price)

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/881249.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号