Question:

Which of the following statement is correct with respect to exception handling in python?

Show Hint

A try block must have at least one except or finally block.
You can associate multiple except blocks with one try to handle different exceptions separately.
Updated On: Sep 7, 2026
  • There can be multiple except clause associated with a single try block.
  • The finally clause cannot be used if there are more than one except clause present with a try block.
  • The raise statement is mandatory in a try block.
  • An except clause can exist without any try block.
Show Solution
collegedunia
Verified By Collegedunia

The Correct Option is A

Solution and Explanation

Concept:
Python provides robust error-handling constructs using try, except, else, and finally blocks.
A single piece of monitored code can potentially encounter different runtime errors, such as ZeroDivisionError, ValueError, or FileNotFoundError.

Step 1: Assessing Multiple 'except' Clauses:

A single try block can have multiple distinct except clauses attached to it.
This enables the program to handle different exception classes selectively and provide tailored recovery routines for each error type.
Thus, statement (A) is completely true.

Step 2: Checking the Other Statements:

- Statement (B) is incorrect because a finally block can be placed after any number of except blocks.
- Statement (C) is incorrect because raise is completely optional inside a try block; built-in exceptions are raised automatically by Python.
- Statement (D) is incorrect because an except clause cannot exist on its own; it requires a preceding try block.
Final Answer:
Statement (A) is the only correct statement regarding exception handling in Python.
Was this answer helpful?
0
0