Docsity

Basic Concepts of Computing: Error Handling and Exceptions, Study notes of Computer Science

Toggle sidebar
bg1
ECS 10, Basic Concepts of Computing Spring Quarter 2009
Version of April 30, 2009 at 7:38 PM Page 1 of 1
Outline for May 1, 2009
Reading: text, §7.4–7.6
1. Conditionals for error checking
a. Quadratic: check roots are real (see quad-e1.py)
b. Three points on the same line (see line.py)
2. Exceptions
a. try … except
b. Three points on the same line (see line2.py)
c. Quadratic: check for bad input (see quad-e2.py)
d. Style: avoid exception line without type of exception!
3. Some common exceptions
a. ZeroDivisionError
b. TypeError
c. SyntaxError
d. NameError
e. IOError
f. How to figure out what an error is
4. Design example: compute minimum of three values
a. First: direct comparison (see least1.py)
b. Second: cascade (see least2.py)

Partial preview of the text

Download Basic Concepts of Computing: Error Handling and Exceptions and more Study notes Computer Science in PDF only on Docsity!

ECS 10, Basic Concepts of Computing Spring Quarter 2009 Version of April 30, 2009 at 7 : 38 PM Page 1 of 1

Outline for May 1, 2009

Reading : text, §7.4–7.

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