Skip to main contentSkip to solution

A / An_________ block will be executed only if exception is raised in the try block, in Python.

Solution

✅ Correct Option: 4

The except block runs only when an exception is raised in the try block. Python then matches the exception to an except clause and runs its code.


Option 1: else runs only when the try block raises no exception, which is the opposite of the question.

Option 2: catch is used in Java and C++, but it is not a Python keyword.

Option 3: finally runs every time, 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