Skip to main contentSkip to solution

The statements inside ______ block are always executed whether an exception has occured in the try block or not.

Solution

✅ Correct Option: 3

The finally block is always executed, whether or not the try block raised an exception, and whether or not it was handled. It is used for clean-up work such as closing files or releasing resources.


Except (Option 1): runs only when an exception occurs in the try block, and only if its type matches.

Catch (Option 2): this is the keyword in Java and C++ for handling exceptions, and it also runs only when an exception occurs. Python uses except instead.

Assert (Option 4): a statement that checks a condition and raises AssertionError if it is false. It is not a block that always runs.

Keyboard Shortcuts

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