Courseiva
Computer Programming and Python FundamentalsmediumMultiple ChoiceObjective-mapped

PCEP Computer Programming and Python Fundamentals Practice Question

Exhibit

Refer to the exhibit.

Error output from a Python script:
Traceback (most recent call last):
  File "script.py", line 3, in <module>
    result = 10 / 0
ZeroDivisionError: division by zero

Refer to the exhibit. What type of error occurred, and which line caused it?

⚠ Common exam trap

The PCEP exam often tests the distinction between compile-time errors (SyntaxError) and runtime errors (like ZeroDivisionError), and candidates mistakenly choose SyntaxError because they think any error in code is a syntax problem, but the code is syntactically correct — the error only occurs when the line executes.

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 at line 3

The code attempts to divide by zero on line 3, which raises a ZeroDivisionError. In Python, any division where the denominator is zero (e.g., `x / 0`) triggers this runtime exception, and the traceback points to the exact line where the division occurs.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • NameError at line 3

    Why it's wrong here

    NameError occurs for undefined variables, not division.

  • SyntaxError at line 1

    Why it's wrong here

    Syntax errors are detected before execution; this is a runtime error.

  • ValueError at line 0

    Why it's wrong here

    ValueError for invalid literal, not division by zero.

  • ZeroDivisionError at line 3

    Why this is correct

    The output explicitly states ZeroDivisionError on line 3.

About these practice questions

One of 498 original PCEP practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

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.