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