12.5. Building a Simulation - 2ΒΆ

Now that we have a working function, we can focus on using the function. Look for the spot with missing code at line 28. Add the needed code to complete the accumulator pattern to count up the number of times result ends up as True. The expected answer is around 80% - about 8 times out of 10 you should get at least 5 heads in a row if you flip a coin 100 times.

If you run into troubles, here are some debugging tips:

Before you keep reading...

Making great stuff takes time and $$. If you appreciate the book you are reading now and want to keep quality materials free for other students please consider a donation to Runestone Academy. We ask that you consider a $10 donation, but if you can give more thats great, if $10 is too much for your budget we would be happy with whatever you can afford as a show of support.

You have attempted 1 of 3 activities on this page