Course Level
CS1
Knowledge Unit
Fundamental Programming Concepts
Collection Item Type
Assignment
Synopsis

In this assignment students work either individually or in pairs to estimate pi with a Monte Carlo simulation. Students simulate throwing darts at a square with a circle inscribed in the middle by generating random pairs of (x, y) coordinates, keeping track of the ratio of darts that hit the circle. They must write two functions: one that throws a given number of darts, and one that continues throwing darts until the estimated value for pi is within a given tolerance. This assignment reviews random number generation and loops, as well as requiring students to adequately comment and decompose their code. It is particularly useful for students who need additional practice with loops.

Recommendations

Integrate pair programming when it is appropriate for students to collaborate on a lab, assignment, or project. The “driver” controls the mouse and the keyboard, while the “navigator” makes suggestions, points out errors, and asks questions. Partners routinely switch roles to gain the benefits of each role.

Engagement Highlights

Uses games to Employ Meaningful and Relevant Content.

Engagement Practices Employed

Materials and Links

Materials

Computer Science Details

Programming Language
Python

Material Format and Licensing Information

Creative Commons License
CC BY-NC