StudyToCert

All certifications / PCEP / Lessons

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

Propagating exceptions through function boundaries and deciding where to handle them

▶ Watch the overview video

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

An exception does not have to be handled in the function where it is raised. If a function has no matching except for an exception, the function stops immediately, and the exception is passed (propagated) to the code that called it, at the point of the call. If that caller does not handle it either, it moves up again, through each calling function in turn. If it reaches the top level of the program without being handled, Python prints a traceback and the program ends. This behaviour is what lets you separate the code that detects a problem from the code that decides what to do about it.

Free account

Keep reading for free

Create a free StudyToCert account to read the rest of this lesson: 7 more sections, 6 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