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)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)