Outline for October 20, 2022

Reading: §4.5
Assignment:Homework 2, due October 20, 2022


  1. Using random numbers
    1. Problem: compute π by tossing darts at a unit square
    2. First build routine to simulate dart toss at unit square [mc-1.py]
    3. Then build routine to see if co-ordinates are in unit circle [mc-2.py]
    4. Then build routine to read in number of tosses [mc-3.py]
    5. Put it all together [mc-4.py]
    6. Graphics! [mc-5.py]

  2. More recursion
    1. Sum of digits [sumdigits.py]
    2. Greatest common divisor [gcd.py]
    3. Nested lists: is an item in a list? [isinlist.py]

UC Davis sigil
Matt Bishop
Office: 2209 Watershed Sciences
Phone: +1 (530) 752-8060
Email: mabishop@ucdavis.edu
MHI 289I, Programming in Health Informatics
Version of October 18, 2022 at 8:04PM

You can also obtain a PDF version of this.

Valid HTML 4.01 Transitional Built with BBEdit Built on a Macintosh