Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python Please! 2 9 . 8 LAB: Consecutive heads Given main ( ) and GVCoin class, complete function consecutive _ heads ( ) that counts

Python Please! 29.8 LAB: Consecutive heads
Given main() and GVCoin class, complete function consecutive_heads() that counts and returns the number of flips taken to achieve a
desired number of consecutive heads without a tails. Function consecutive_heads() 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 pseudo-random number generator with a fixed seed
value. The program uses a seed value of 15 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 pseudo-random numbers.
Ex: If the GVCoin object is created with a seed value of 15 and the desired number of consecutive heads is 5, then the function
consecutive_heads() returns 16 and the program outputs:
Total number of flips for 5 consecutive heads: 16
import random
class GVCoin :
def_init_(self, seed):
random.seed (seed)
self._is_heads = True
self. heads =0
self.flips =
def num_flips(self):
return self.flips
def num_heads(self):
return self. heads
def num_tails(self):
return self.flips - self.heads
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Securing SQL Server Protecting Your Database From Attackers

Authors: Denny Cherry

1st Edition

1597496251, 978-1597496254

More Books

Students also viewed these Databases questions

Question

Develop clear policy statements.

Answered: 1 week ago

Question

Draft a business plan.

Answered: 1 week ago

Question

Describe the guidelines for appropriate use of the direct plan.

Answered: 1 week ago