Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

6 . Limit flips The function flips uses the module random to flip a coin a certain number of times. It keeps going as long

6. Limit flips
The function flips uses the module random to flip a coin a certain number of times. It keeps going as long as it sees heads, stopping at the first tails. It then returns the number of heads it saw. Try calling this function in Python:
codio@mike-panther:~/workspace/exercise2$ python
>>> import funcs
>>> funcs.flips()
As you can see, the Terminal hangs and becomes unresponsive. To get control back, you need to press Ctrl-C. In Codio, this can take a long time to respond, and if you hit too many times you can lock up the Terminal. If it takes too long, close the Terminal window and reopen it from the Tools menu.
Obviously this is going to make debugging difficult. So the first thing to do is to limit the loop. You are going to add some code to limit the number of times that the loop will execute. Replace the code

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

Put Your Data To Work 52 Tips And Techniques For Effectively Managing Your Database

Authors: Wes Trochlil

1st Edition

0880343079, 978-0880343077

More Books

Students also viewed these Databases questions

Question

a. Describe the encounter. What made it intercultural?

Answered: 1 week ago