-
Notifications
You must be signed in to change notification settings - Fork 0
/
sandwich.py
50 lines (40 loc) · 1.74 KB
/
sandwich.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# there are some kinks to work out but it's good enough
import pyinputplus as pyip
def optionsWithPrices(options):
menu = ''
for key, price in options.items():
menu += f'{key} {str(price)} '
return menu
print('What kind of sandwich would you like?')
breadTypes = {'wheat': 0.30, 'white': 0.25, 'sourdough': 0.50}
proteinTypes = {'chicken': 0.50, 'turkey': 0.75, 'ham': 0.45, 'tofu': 0.50}
cheeseTypes = {'cheddar': 0.15, 'swiss': 0.15, 'mozzarella': 0.15}
extraTypes = {'mayo': 0, 'lettuce': 0, 'tomato': 0, 'mustard': 0.15}
breadPrompt = 'What kind of bread would you like?' + \
optionsWithPrices(breadTypes) + '\n'
bread = pyip.inputMenu(list(breadTypes.keys()),
prompt=breadPrompt)
proteinPrompt = 'What kind of protein would you like? ' + \
optionsWithPrices(proteinTypes) + '\n'
protein = pyip.inputMenu(list(proteinTypes.keys()),
prompt=proteinPrompt)
wantsCheese = pyip.inputYesNo('Would you like cheese?\n')
if wantsCheese == 'yes':
cheesePrompt = 'What kind of cheese would you like? ' + \
optionsWithPrices(cheeseTypes) + '\n'
cheese = pyip.inputMenu(list(cheeseTypes.keys()), prompt=cheesePrompt)
extraChoices = []
for extra in extraTypes.keys():
extraPrompt = 'Would you like ' + extra + \
' ? ' + str(extraTypes[extra]) + '\n'
extraChoice = pyip.inputYesNo(extraPrompt)
if extraChoice == 'yes':
extraChoices.append(extra)
extrasSum = 0
for extra in extraChoices:
extrasSum += extraTypes[extra]
sandwichPrice = breadTypes[bread] + \
proteinTypes[protein] + cheeseTypes[cheese] + extrasSum
quantity = pyip.inputInt('How many sandwiches would you like?', min=1)
total = quantity * sandwichPrice
print('The total will be $' + str(total))