Question: Exercise 5: Flippin' Coins Note: The random library randint(x,y) returns a random integer between x and y. We can simulate a coin flip by selecting

Exercise 5: Flippin' Coins Note: The random library randint(x,y) returns a random integer between x and y. We can simulate a coin flip by selecting a random integer between 0 and 1. Sometimes the number is 1 (heads), and sometimes the number is 0 (tails). Write a python script to count how many flips are required before we see heads 5 times total, [ ]: import random coin = random.randint(0,1) print(coin) [41]: import random n = 5 coin = random.randint(0,1) def coinToss(coin): n = 1 return random.randint(,1) while (coin == 1): ne n+1 print (coin) coinToss(coin) [41]: 1 Write a python script to count how many flips are required before we see heads 5 times in a row. Hint: reset your counter to zero when tails occurs [ ]: ## your algorithm here
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
