PCEP Practice Question: Data Types, Variables, Basic I/O and Operators
Given x = 5, which of the following assignments will cause a runtime error?
⚠ Common exam trap
The trap here is that candidates may mistakenly think any operator can handle zero as a divisor or confuse floor division with modulo, but The PCEP exam specifically tests that `//` with a zero divisor raises a runtime error, not a syntax error or silent failure.
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
✓
x //= 0
Division by zero is undefined in Python, and the floor division assignment operator `//=` with a divisor of 0 raises a `ZeroDivisionError` at runtime. The other operators (`**=`, `-=`, `+=`) perform valid arithmetic on the integer 5 and do not cause errors.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
x **= 2
Why it's wrong here
x **= 2 is valid augmented assignment: it raises the existing integer 5 to the power 2 and rebinds x to 25. It is tempting to flag because exponentiation looks unusual in an assignment operator, but Python supports it for numeric types, so no runtime error arises.
- ✗
x -= 3
Why it's wrong here
x -= 3 is valid augmented assignment: it subtracts 3 from the existing integer 5 and rebinds x to 2. It is tempting to flag because augmented assignment appears to modify an immutable int in place, yet Python rebinds the name instead, so execution succeeds without error.
- ✓
x //= 0
Why this is correct
Floor division by zero raises ZeroDivisionError at runtime, since Python cannot compute an integer quotient when the divisor is zero. The augmented assignment evaluates x // 0 immediately, satisfying the stem's condition of causing a runtime error rather than a syntax or name error.
- ✗
x += 2
Why it's wrong here
x += 2 is valid augmented assignment: it adds 2 to the existing integer 5 and rebinds x to 7. It is tempting to flag because augmented assignment looks like it mutates an immutable int, but rebinding is exactly what Python does, so no runtime error occurs.
Go deeper
Related to this question
About these practice questions
One of 482 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 →
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.