Skip to main contentSkip to solution

What is an exception in Python?

Solution

✅ Correct Option: 3

An exception in Python is an error event that occurs while the program is running (at runtime) and disrupts the normal flow of execution. Examples are ZeroDivisionError, ValueError and FileNotFoundError. If it is not handled, the program stops and prints a traceback. It can be handled using try and except.


Option 1: a logical error does not raise an exception. The program runs without crashing but gives a wrong output.

Option 2: a syntax error is detected when the code is parsed, before execution starts, so the program does not run at all.

Option 4: Python has no separate compilation step that students see, and errors found before running are syntax errors, not exceptions.

Keyboard Shortcuts

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