PCEP Practice Question: Functions, Tuples, Dictionaries and Exceptions
Exhibit
Traceback (most recent call last):
File "app.py", line 10, in <module>
result = divide(10, 0)
File "app.py", line 5, in divide
return a / b
ZeroDivisionError: division by zeroRefer to the exhibit. What type of exception occurred?
⚠ Common exam trap
The PCEP exam often tests the distinction between the generic `ArithmeticError` and its specific subclass `ZeroDivisionError`, trapping candidates who think the parent class is raised directly instead of the more specific exception.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
ZeroDivisionError
The code attempts to divide by zero (e.g., `10 / 0`), which raises a `ZeroDivisionError` in Python. This is a specific built-in exception for division or modulo operations where the divisor is zero.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
ZeroDivisionError
Why this is correct
Correct; as shown in the traceback.
- ✗
TypeError
Why it's wrong here
Incorrect; no type mismatch.
- ✗
ValueError
Why it's wrong here
Incorrect; it's a division by zero error.
- ✗
ArithmeticError
Why it's wrong here
ZeroDivisionError is a subclass of ArithmeticError, but the specific exception is ZeroDivisionError.
Go deeper
Related to this question
About these practice questions
This PCEP question is part of Courseiva's 498-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This PCEP practice question is part of Courseiva's free Python Institute certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the PCEP exam.