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
- Run the code. What fraction of flips are heads?
- Change
nto 10, then 10,000. What happens to the fraction? - Add code that finds the longest run of heads in a row.
- The file
flips.csvholds the class's results: each of 20 students flipped coins A, B and C 100 times. Read it withpandas.read_csv("flips.csv"). Is one coin unfair? How sure are you?
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?