Outline for May 1, 2009

Reading: §7.4–7.6


  1. Conditionals for error checking
    1. Quadratic: check roots are real (see quad-e1.py)
    2. Three points on the same line (see line.py)
  2. Exceptions
    1. try ... except
    2. Three points on the same line (see line2.py)
    3. Quadratic: check for bad input (see quad-e2.py)
    4. Style: avoid exception line without type of exception!
  3. Some common exceptions
    1. ZeroDivisionError
    2. TypeError
    3. SyntaxError
    4. NameError
    5. IOError
    6. How to figure out what an error is
  4. 4. Design example: compute minimum of three values
    1. First: direct comparison (see least1.py)
    2. Second: cascade (see least2.py)