Python Exception Handling: try/except/else/finally
Medium-level multiple-choice quiz exploring correct usage, behavior, and edge cases of try, except, else, and finally in Python.
Try this quiz
Play through the questions and see your score instantly
Ready to test your knowledge?
25 questions · Quick play · Instant results
Make your own quiz videos
Turn any topic into a polished video quiz — with AI-powered questions, voiceover, and animations. No video editing skills needed.
Unlimited quizzes, free to start
Create as many quizzes as you want. Describe your topic and AI builds the questions, answers, and explanations for you.
Customise everything
Pick from stunning templates, tweak colours and fonts, add your branding, and choose between vertical or landscape formats.
Export-ready videos
Download HD videos optimised for TikTok, YouTube Shorts, Instagram Reels, or full-length YouTube — one click, no editing.
No credit card required
Quiz Questions & Answers
Review every prompt, the correct responses, and helpful context to prep for your own run-through.
Question 1: What does the else clause of a try/except block run?
Runs only if an exception was caught by except
Runs only if no exception was raised in the try block
Runs always, even if an exception is raised
Runs only if finally raised an exception
Question 2: Which keyword ensures cleanup code runs regardless of exceptions?
else
raise
finally
with
Question 3: What happens to an exception re-raised in an except block if not handled later?
It is automatically converted to a RuntimeError
It propagates up the call stack possibly terminating the program
It triggers the else block
It becomes suppressed silently
Question 4: Which except clause matches multiple specific exception types?
List exception names separated by semicolons
Use a tuple of exception classes like except (TypeError, ValueError):
Write multiple except blocks but only the first runs
Use or between exception classes inside except
Question 5: Where should you place a return statement to ensure finally still runs?
finally is skipped when return appears in try
Return cancels finally only if inside except
Finally runs only for uncaught exceptions with return
finally still runs even if return is executed in try or except
Question 6: What does except Exception: commonly catch?
Only syntax errors at compile time
Most user-defined and built-in exceptions excluding system-exiting ones
All possible exceptions including KeyboardInterrupt
Only ValueError and TypeError
Question 7: Which of these is a best practice when catching exceptions?
Always use bare except to simplify code
Catch specific exceptions rather than using a bare except
Suppress exceptions silently in production
Rely on finally to handle logic-specific errors
Question 8: How can you access the exception instance inside an except block?
Use the raise variable inside finally
Use except Exception as e: to bind the instance to a name
Access it via global variable last_exception
Use sys.exception() function
Question 9: What effect does raise without arguments have inside an except block?
Raises a new generic Exception
Re-raises the current exception being handled
Raises a SyntaxError at runtime
Suppresses the current exception
Question 10: If both except and finally have return statements, which value is returned?
Python raises an error for multiple returns
The value returned in finally overrides earlier returns
Both values are returned as a tuple
The except return always wins over finally
Question 11: Which exception group is not caught by except Exception: ?
FileNotFoundError
KeyboardInterrupt (a BaseException subclass)
ValueError
TypeError
Question 12: Which pattern helps avoid swallowing unexpected exceptions?
Catch specific exceptions and re-raise or log others
Wrap every line in its own try
Always use finally without except
Use bare except and ignore errors
Question 13: In what order are blocks executed for try, except, else, finally on a successful try?
try, else, finally
try, finally, else
try, except, finally
except, else, finally
Question 14: Which scenario is an appropriate use for else after try?
Use else to silence exceptions
Always place cleanup code there instead of finally
Run code that should only execute if try succeeded, keeping exceptions separate
Use else to catch exceptions not handled by except
Question 15: What is the effect of using a bare except: with no exception type?
It only catches exceptions raised in finally
It behaves the same as except Exception:
It catches all exceptions, including system-exiting ones, which is risky
It only catches RuntimeError
Question 16: Which is a correct way to handle an error but still see its traceback for debugging?
Log exception with traceback.format_exc() then re-raise if needed
Overwrite exception object with None
Suppress traceback by printing a short message
Call sys.exit inside except to dump traceback
Question 17: Which is true about exception chaining with raise NewError from original?
It duplicates the original exception object
It links the new exception to the original for clearer tracebacks
It suppresses the original exception completely
It converts the original to a string only
Question 18: Why avoid except Exception as e: and then pass with no action?
It silently hides errors and makes bugs hard to find
It raises a syntax error
It automatically retries the block
It causes finally to skip
Question 19: What happens if an exception is raised inside finally?
The original exception is always preserved
The exception is ignored automatically
That exception replaces any earlier exception or return value
The interpreter retries the try block
Question 20: Which construct is preferable for resource management instead of try/finally cleanup?
Wrap resources in a loop and break on error
Avoid cleanup and rely on GC
Use context managers with the with statement when available
Use bare except to handle resource errors
Question 21: Which is a correct way to catch any exception but still get the original traceback?
Use except Exception as e: then raise with raise from e to chain
Use sys.tracebacklimit = None and then re-raise
Use return inside except to forward traceback
Convert exception to string and raise ValueError
Question 22: When should you use multiple except blocks versus a single except with tuple?
When each exception type needs distinct handling or different messages
When you want to catch nothing
When exceptions are all subclasses of Exception
When you want to guarantee order-independent handling
Question 23: What is the recommended action when an exception indicates programmer error?
Fix the code instead of catching the exception at runtime
Use finally to suppress it
Silently ignore the exception in production
Wrap it in a generic exception and continue
Question 24: What does the variable __context__ on an exception hold?
The stack frame where exception was created
The previous exception that was active when this exception was raised
A boolean indicating if exception was re-raised
A string description of the exception
Question 25: Which pattern safely retries an operation a limited number of times upon specific exceptions?
Use bare except inside infinite loop
Loop with try/except catching specific errors and break on success or limit retries
Wrap in with to automatically retry
Use finally to repeat the try block automatically