Week 2 • Friday

Block 20: Mini-Project: NumPy Numeric Simulation

Combine arrays, broadcasting, and aggregations in one project.

Concepts

Code Examples

See exercise below.

Exercise

Simulate 10,000 coin flips using np.random.randint(0,2). Count heads and tails. Compute running proportion of heads and find when it first settles within 1% of 0.5. Bonus: Print a text bar chart of the frequency of each outcome.

Homework

Reflection: Write your personal NumPy cheat sheet — the 10 most useful operations you learned.