Python together: simulating coin flips

Everyone in your group edits the same code. Anyone can press Run; the output appears for the whole group. Python runs in your browser.

Your task
  1. Run the code. What fraction of flips are heads?
  2. Change n to 10, then 10,000. What happens to the fraction?
  3. Add code that finds the longest run of heads in a row.
  4. The file flips.csv holds the class's results: each of 20 students flipped coins A, B and C 100 times. Read it with pandas.read_csv("flips.csv"). Is one coin unfair? How sure are you?
Loading Python…
Data file: flips.csv (60 rows)

  

Reflect

In your own words: why does the fraction of heads get closer to 0.5 as n grows? And how did your group decide whether coin C is unfair — what would change your mind?