Recall & Review
beginner
What is multiple exception handling in Python?
It is a way to catch and handle more than one type of error in a single try block using multiple except clauses.
Click to reveal answer
beginner
How do you write multiple except blocks in Python?
You write several except blocks after a try block, each specifying a different exception type to handle.
Click to reveal answer
beginner
What happens if an exception is not caught by any except block?
The program stops and shows an error message called a traceback.
Click to reveal answer
intermediate
Can you catch multiple exceptions in one except block? How?
Yes, by grouping exceptions in a tuple after except, like except (TypeError, ValueError):
Click to reveal answer
intermediate
Why is it useful to handle multiple exceptions separately?
Because different errors may need different fixes or messages, so handling them separately helps make the program clearer and safer.
Click to reveal answer
Which keyword starts the block where you try code that might cause errors?
✗ Incorrect
The try block contains code that might raise exceptions.
How do you catch both ValueError and TypeError in one except block?
✗ Incorrect
Use a tuple of exceptions inside parentheses after except.
What happens if an exception is raised but no except block matches it?
✗ Incorrect
Uncaught exceptions cause the program to stop and print an error traceback.
Which of these is a correct way to handle multiple exceptions separately?
✗ Incorrect
You write separate except blocks for each exception type.
Why might you want to handle exceptions separately instead of together?
✗ Incorrect
Different errors may need different fixes or messages.
Explain how to use multiple except blocks to handle different exceptions in Python.
Think about writing one except block for each error you want to catch.
You got /4 concepts.
Describe how to catch multiple exceptions in a single except block and why you might do this.
Use parentheses and commas to group exceptions.
You got /3 concepts.