StudyToCert

All certifications / PCEP / Lessons

PCEP – Certified Entry-Level Python Programmer PCEP-30-02 · Domain 4: Functions and exceptions

The exception hierarchy: BaseException, Exception, SystemExit, KeyboardInterrupt, ArithmeticError, LookupError

▶ Watch the overview video

Last reviewed September 30, 2026 · Leer en español

When something goes wrong at run time, Python raises an exception: an object describing the error, with a type (its class) and usually a message. Exceptions are organised into a class hierarchy, a family tree in which more specific exception types inherit from more general ones. This matters because an except clause that names a class also catches every class below it in the tree. Knowing the tree lets you predict which handler runs, and lets you choose how broad or narrow each handler should be.

Free account

Keep reading for free

Create a free StudyToCert account to read the rest of this lesson: 7 more sections, 7 key terms, a real-world example, an exam tip and self-check questions. Every lesson, lab and practice test is free with an account.

Sign up free Log in

Study PCEP for free
A week-by-week plan with every lesson, quizzes, checkpoint tests, a practice exam and hands-on labs.
Open the PCEP study plan