Skip to main contentSkip to solution

Which of the following statements are correct with respect to handling exceptions in Python?

A. The try block is used to catch exceptions.

B. The except block is executed if an exception occurs.

C. You can have multiple except blocks.

D. The else block executes if no exceptions occur.

Solution

✅ Correct Option: 3

All four statements are correct, so Option 3 is right.

A: The try block holds the code that may raise an exception, and it works together with except to catch it.

B: The except block runs only when an exception occurs in the try block.

C: A try statement can have several except blocks, each handling a different exception type, such as ZeroDivisionError or ValueError.

D: The else block runs only when the try block finishes without raising any exception.

A finally block, if present, runs whether or not an exception occurs.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question