Course Home | Class Schedule | Moodle CMS | Git Submission | Perusall | Tutoring

Saint Louis University

Computer Science 1300/5001
Introduction to Object-Oriented Programming

Michael Goldwasser

Fall 2019

Computer Science Department

Homework Assignment 11

Please make sure you adhere to the policies on academic integrity.


Consider a single experiment of flipping a fair coin until an outcome of "heads" and counting the number of flips that occur. Note well that randrange(2) will return either 0 or 1, with equal probability.

Write a for loop that repeats 10,000 trials of this experiment, reporting

For example, my program output the following for a 10,000 trial experiment:

Average number of flips 2.0142
Maximum number of flips 17

Of course, since randomness is involved, another such experiment would presumably get different results.

In submitting this homework, please give us the source code you use for the analysis, as well as sample output for one run of your program.


Michael Goldwasser
CSCI 1300/5001, Fall 2019
Last modified: Sunday, 22 December 2019
Course Home | Class Schedule | Moodle CMS | Git Submission | Perusall | Tutoring