Question: Python Please! 2 9 . 8 LAB: Consecutive heads Given main ( ) and GVCoin class, complete function consecutive _ heads ( ) that counts
Python Please! LAB: Consecutive heads
Given main and GVCoin class, complete function consecutiveheads that counts and returns the number of flips taken to achieve a
desired number of consecutive heads without a tails. Function consecutiveheads has a GVCoin object and an integer representing the
desired number of consecutive heads without a tails as parameters.
Note: For testing purposes, a GVCoin object is created in the main function using a pseudorandom number generator with a fixed seed
value. The program uses a seed value of during development, but when submitted, a different seed value will be used for each test case.
Refer to the textbook section on random numbers to learn more about pseudorandom numbers.
Ex: If the GVCoin object is created with a seed value of and the desired number of consecutive heads is then the function
consecutiveheads returns and the program outputs:
Total number of flips for consecutive heads:
import random
class GVCoin :
definitself seed:
random.seed seed
self.isheads True
self. heads
self.flips
def numflipsself:
return self.flips
def numheadsself:
return self. heads
def numtailsself:
return self.flips self.heads
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
