PRACTICE • LEARN • GROW
Module 9: Exception Handling - Final Quiz MCQs
Solve topic-wise placement questions and improve your skills.
Module 9: Exception Handling - Final Quiz Progress
0 of 11 completed
0%
Topic Track
You are viewing MCQs in preview mode. Log in to select options, submit answers, and track your progress.
Log In to Answer
1
When does the
else block execute in a Python try-except-else-finally statement?
A.
When an exception occurs in the try block
B.
ONLY when the try block executes successfully with ZERO exceptions raised
C.
Always, right before finally
D.
Only when the catch block re-raises an error
Explanation & Key
Correct Answer:
2
Which block in a try-except structure is GUARANTEED to execute regardless of whether an exception occurred or was handled?
A.
try
B.
except
C.
else
D.
finally
Explanation & Key
Correct Answer:
3
What will be printed by the following try-except-else-finally flow?
try:
x = 10 / 2
except ZeroDivisionError:
print("Zero")
else:
print("Success")
finally:
print("Done")
A.
Success Done
B.
Done
C.
Zero Done
D.
Success
Explanation & Key
Correct Answer:
4
What is the keyword used in Python to manually trigger or fire an exception?
A.
throw
B.
raise
C.
fire
D.
emit
Explanation & Key
Correct Answer:
5
To create a custom application exception, which base class should your custom class inherit from?
A.
BaseException directly
B.
Exception (or any standard Exception subclass)
C.
Error
D.
object directly
Explanation & Key
Correct Answer:
6
What programming philosophy is summarized by EAFP in the Python community?
A.
Early Allocation For Performance
B.
Easier to Ask for Forgiveness than Permission (attempting an operation and catching exceptions rather than pre-checking)
C.
Ensure All Functions Pass
D.
Explicit Arguments For Parameters
Explanation & Key
Correct Answer:
7
How can you catch multiple distinct exception types in a single
except clause?
A.
except ValueError and TypeError:
B.
except (ValueError, TypeError):
C.
except ValueError | TypeError:
D.
except [ValueError, TypeError]:
Explanation & Key
Correct Answer:
8
What will the following function return?
def test():
try:
return 10
finally:
return 20
print(test())
A.
10
B.
20
C.
None
D.
SyntaxError
Explanation & Key
Correct Answer:
9
Why does a generic
except Exception: block NOT catch KeyboardInterrupt (Ctrl+C)?
A.
Because KeyboardInterrupt is handled by the hardware timer
B.
Because KeyboardInterrupt inherits directly from BaseException, not Exception, preventing normal exception handlers from trapping user termination
C.
Because KeyboardInterrupt is a warning, not an exception
D.
Because Python ignores Ctrl+C during execution
Explanation & Key
Correct Answer:
10
What syntax is used in Python 3 to perform explicit Exception Chaining, preserving the root cause of an error?
A.
raise NewError() with orig_err
B.
raise NewError() from orig_err
C.
raise NewError().caused_by(orig_err)
D.
raise NewError() -> orig_err
Explanation & Key
Correct Answer:
11
What happens if you execute a bare
raise inside an except block without naming an exception?
A.
Raises a RuntimeError
B.
Re-raises the active exception currently being handled
C.
Does nothing
D.
Exits the program immediately
Explanation & Key
Correct Answer:
Question Palette
Answered
Current
Not Attempted
Wrong