Outline for November 19, 2020

Reading: §3.7, 4.5, 7.7
Due: Homework 4, due December 1, 2020


  1. Handling exceptions
    1. except [except0.py]
    2. except exceptcode [except1.py]
    3. else [except2.py]
    4. except exceptcode as msgvar [except3.py]
    5. finally [except4.py]
    6. Exceptions in a function: who handles them? [except5.py, except6.py]
    7. Using global variables as error flags [except6a.py]
    8. raise exceptcode message [except7.py]

  2. Randomness [random.py]
    1. Pseudorandomness vs. randomness
    2. random returns random number between 0.0 and 1.0 (but never 1.0)
    3. randint(low, high) returns random integer between low and high inclusive
    4. seed(n) uses a fixed starting point for the sequence
    5. choice(seq) returns a randomly-selected element of the sequence seq
    6. choices(seq, k=n) returns a list of n randomly-selected elements of the sequence seq
    7. shuffle(seq) shuffles the elements of the sequence seq in place


UC Davis sigil
Matt Bishop
Office: 2209 Watershed Sciences
Phone: +1 (530) 752-8060
Email: mabishop@ucdavis.edu
MHI 289I, Programming for Health Informatics
Version of November 17, 2020 at 10:42PM

You can also obtain a PDF version of this.

Valid HTML 4.01 Transitional Built with BBEdit Built on a Macintosh