| Hosted by CoCalc | Download
Kernel: Python 3 (system-wide)
import numpy as np import random
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)
count = 0 for i in range (10000): while coin_flip_head_streak() < 7: count += 1 print(count/10000)
2.2002