-
Notifications
You must be signed in to change notification settings - Fork 0
/
Project_01.py
49 lines (48 loc) · 1.47 KB
/
Project_01.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
#Project 01
## Given dictionary
import random
questions = {
"strong": "Do ye like yer drinks strong?",
"salty": "Do ye like it with a salty tang?",
"bitter": "Are ye a lubber who likes it bitter?",
"sweet": "Would ye like a bit of sweetness with yer poison?",
"fruity": "Are ye one for a fruity finish?",
}
ingredients = {
"strong": ["glug of rum", "slug of whisky", "splash of gin"],
"salty": ["olive on a stick", "salt-dusted rim", "rasher of bacon"],
"bitter": ["shake of bitters", "splash of tonic", "twist of lemon peel"],
"sweet": ["sugar cube", "spoonful of honey", "spash of cola"],
"fruity": ["slice of orange", "dash of cassis", "cherry on top"],
}
## solve
# use question to get user's tastes (multiple value)
# match randomly with ingredient
def ask_user():
taste=[]
for x,y in questions.items():
print(y)
ans=input('Please enter YES (Y) or No (N): ')
if ans== 'Y':
taste.append(x)
elif ans== "N":
continue
else:
print ("Error in answer, Exit !:")
exit
return(taste)
def return_ing(taste):
ans=[]
for j in ingredients.keys():
if j in taste:
ans.append(ingredients.get(j)[random.randint(0,2)])
return (ans)
def print_out(taste,ans):
print('Tastes you chose: ',taste)
print('Ingredient added: ',ans)
return()
# main
# not sure this is what the Project ask by using def
Input=ask_user() # ask all questions
Ans=return_ing(Input)
print_out(Input,Ans)