Courseiva
Data Types, Variables, Basic I/O and OperatorshardMultiple ChoiceObjective-mapped

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

    Works fine, x becomes 25.

  • x -= 3

    Why it's wrong here

    Works fine, x becomes 2.

  • x //= 0

    Why this is correct

    Integer division by zero raises ZeroDivisionError.

  • x += 2

    Why it's wrong here

    Works fine, x becomes 7.

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.