Let's play a game:
There is one weighted coin; the rest are fair. You have to figure out which one is unfair... to leave the classroom.Good luck!
Homework
Flip a coin 100 times. Record the sequence of flips, eg, H, T, T, H... Count He number of heads and number of tails. What was your longest streak?
Comments
import random
heads = 0
tails = 0
for x in range(1, 101):
randomInt = random.randint(1, 2)
if randomInt == 1:
print(str(x) + ": Heads")
heads += 1
else:
print(str(x) + ": Tails")
tails += 1
print()
print("HEADS:" + str(heads))
print("TAILS:" + str(tails))
1: Tails
2: Tails
3: Heads
4: Heads
5: Heads
6: Tails
7: Tails
8: Heads
9: Heads
10: Tails
11: Heads
12: Tails
13: Tails
14: Tails
15: Tails
16: Tails
17: Tails
18: Heads
19: Heads
20: Heads
21: Tails
22: Tails
23: Tails
24: Heads
25: Heads
26: Heads
27: Heads
28: Tails
29: Tails
30: Heads
31: Heads
32: Heads
33: Heads
34: Heads
35: Tails
36: Tails
37: Heads
38: Tails
39: Heads
40: Heads
41: Heads
42: Tails
43: Tails
44: Heads
45: Tails
46: Tails
47: Tails
48: Heads
49: Tails
50: Tails
51: Tails
52: Heads
53: Tails
54: Heads
55: Tails
56: Heads
57: Tails
58: Heads
59: Tails
60: Tails
61: Tails
62: Tails
63: Heads
64: Tails
65: Tails
66: Heads
67: Tails
68: Heads
69: Heads
70: Heads
71: Heads
72: Heads
73: Heads
74: Heads
75: Heads
76: Heads
77: Heads
78: Heads
79: Tails
80: Heads
81: Tails
82: Heads
83: Tails
84: Heads
85: Heads
86: Heads
87: Tails
88: Heads
89: Heads
90: Heads
91: Tails
92: Heads
93: Heads
94: Tails
95: Tails
96: Tails
97: Heads
98: Tails
99: Tails
100: Tails
HEADS:52
TAILS:48