-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbean_sim.py
More file actions
50 lines (38 loc) · 1.48 KB
/
bean_sim.py
File metadata and controls
50 lines (38 loc) · 1.48 KB
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
import random
melting_pot = []
potluck = []
cup = []
bean_types = ['lima', 'pinto', 'black', 'red']
for i in range(200):
melting_pot.append(random.choice(bean_types))
potluck.append(random.choice(bean_types))
print('Bean cups filled.\n')
print('Type "sample" to get a sample from a specified container ("melting pot" or "potluck") and put the sample into your cup, type "return" to dump your cup\'s contents into a specified container, type "view" to see the beans in your cup, and type "quit" to quit.')
user_input = ''
while True:
user_input = input('>').lower()
if 'sample' in user_input:
if 'melting' in user_input:
print("Sampling 10 beans from melting pot")
for i in range(10):
cup.append(melting_pot.pop(0))
elif 'potluck' in user_input:
print("Sampling 10 beans from potluck")
for i in range(10):
cup.append(melting_pot.pop(0))
elif 'return' in user_input:
if 'melting' in user_input:
print("Dumping cup contents into melting pot")
melting_pot.append(cup)
elif 'potluck' in user_input:
print("Dumping cup contents into potluck")
potluck.append(cup)
cup = []
elif 'view' in user_input:
cup.sort()
print("Your cup contains: " + ', '.join(cup))
elif 'quit' in user_input:
print("Thanks for playing!")
break
else:
print('Invalid input. Please try again.')