Skip to main content
By the end of this module you can do everything below. The objectives and their wording come from the official PCEP-30-03 syllabus.

4.2.1 Explain and recognize basic Python exceptions

  • Explain the purpose of exceptions in Python programs.
  • Explain how an exception interrupts the flow of program execution.
  • Recognize common situations in which Python raises exceptions.
  • Recognize basic built-in exceptions, including ValueError, TypeError, ZeroDivisionError, IndexError, KeyError, and NameError.
  • Relate common exception types to the operations that may cause them.

4.2.2 Handle runtime exceptions with try and except

  • Use try and except to handle runtime exceptions.
  • Handle specific exception types using one or more except branches.
  • Use multiple except branches to handle different exception types.
  • Trace simple exception-handling flow when an exception occurs or does not occur.