The code below is supposed to “flip a coin” 100 times by making a random number that is 0 (heads) or 1 (tails) and keep track of the longest streak of heads that we see. For each repetition, we need to make a random number, then check to see if it is a “heads” (0). Then we will updatethe
headsInARow
counter (like the sample from
Building a Simulation) based on that result by adding one or resetting it to 0. If the
headsInARow
increased (but not if it was reset to 0), we will check and see if it is bigger than
longestStreak
. If so, we will update the
longestStreak
to match
headsInARow
. After all 100 flips are done we will print out the
longestStreak
.
Move the correct blocks from the left to the right and indent them properly. You will use all of the blocks. Make sure to put import random
first.