Outline for January 29, 2018

Reading: §4.4


  1. Unformatted and formatted printing [printing.py]
  2. Calculating π using a Monte Carlo method
    1. How you do it
    2. random module
    3. Building program in modules, including testing routines
    4. First step: computing co-ordinates of dart toss [mc1.py]
    5. Second step: see if a point falls within the unit circle [mc2.py]
    6. Third step: read in a positive integer, with error checking [mc3.py]
    7. Fourth step: put it all together and print the results [mc4.py]

Matt Bishop
Department of Computer Science
University of California at Davis
Davis, CA 95616-8562 USA
Last modified: Version of January 28, 2018 at 11:16PM
Winter Quarter 2018
You can get a PDF version of this