CoCalc Public Filesprep.ipynbOpen with one click!
Author: Kaleb Cruz
Views : 95
Compute Environment: Ubuntu 20.04 (Default)
In [6]:
import numpy as np import random
In [7]:
def coin_flip_head_streak(): streaklist = [] streak = 0 for i in range(100): rand = random.randint(0,1) if(rand == 1): streak += 1 else: if streak: streaklist.append(streak) streak = 0 return np.max(streaklist)
In [8]:
count = 0 for i in range (10000): while coin_flip_head_streak() < 7: count += 1 print(count/10000)
2.2002
In [ ]:
In [ ]: