Learn Without Walls
← Back to Module 12

Module 12: Study Guide

Review key concepts from Error Handling & Next Steps

Key Terms

Exception: An error that occurs during program execution (as opposed to syntax errors which are caught before running).
Traceback: Python's error report showing the chain of calls that led to the error, the file, line number, and error type.
try/except: A construct that catches exceptions and runs alternative code instead of crashing.
raise: A keyword to manually trigger an exception.
Debugging: The process of finding and fixing errors (bugs) in your code.
Print debugging: Adding print statements to trace variable values and program flow.

Lesson 1: Common Python Errors

Lesson 2: try/except/finally

Execution Order

try:       # 1. Try this code first
except:    # 2a. Runs if error occurs (skips else)
else:      # 2b. Runs if NO error (skips except)
finally:   # 3. ALWAYS runs

What to Know

Lesson 3: Debugging Strategies

Lesson 4: Next Steps

Review Questions

1. What is the difference between a SyntaxError and a NameError?

2. In what order do try/except/else/finally blocks execute?

3. Why should you catch specific exceptions instead of using bare except?

4. What is rubber duck debugging and why does it work?

5. How do you use the raise keyword?

6. What are three common beginner mistakes in Python?

Common Mistakes to Avoid