CS 477: Module 1: Numpy Exercise (1.5 Points)
Developed by Professor Tralie and Professor Mongan.Exercise Goals
The goals of this exercise are:- To apply array indexing in numpy
- To use for loops in numpy
The code below does one trial (experiment) of the 10 heads in a row game, but that doesn't give us a very good idea of how long it takes in general. We should do the experiment many times to get a better sense. Your task in this exercise is to put the starter code inside of a for loop that loops through num_trials
times and stores the number of flips it took for each trial as an element in the trials
numpy array. All you should have to do is add a for loop, put all of the code inside, and assign num_flips
to an index in trials
. Then, we can use the power of matplotlib to plot a histogram showing us a distribution of the number of heads it took over all experiments.
Welcome to our online modules system!
Be sure to log in with your Urinus ID
before you proceed.
For example, Professor Tralie's ID is ctralie.
If you are not an Ursinus student, that's fine!
Just make something up, and you can still run everything