PCEP Practice Question: Data Types, Variables, Basic I/O and Operators
Given the following code, which of the following statements are true after execution? (Choose three.)
x = 10 y = 3.0 z = x / y w = x // y
⚠ Common exam trap
The PCEP exam often tests the misconception that floor division (//) returns an int when one operand is a float, or that true division (/) can return an integer, leading candidates to incorrectly select options C or D.
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
✓
The expression x % y is valid.
Option A is correct because x % y uses the modulo operator on an int and a float, which is valid in Python and yields the float remainder 1.0. Option B is correct because x / y performs true division (10 / 3.0), producing the float value approximately 3.3333333333333335. Option E is correct because x // y performs floor division; with a float operand the result is a float, so 10 // 3.0 equals 3.0. Option C is not correct because w is a float (3.0), not an int, since one operand is a float. Option D is not correct because the / operator always returns a float in Python 3, not an integer.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
The expression x % y is valid.
Why this is correct
The modulo operator accepts mixed numeric types in Python, so `x % y` with an integer and a float is valid and evaluates to 1.0. This satisfies the stem's requirement for true statements after execution, since no type restriction prevents combining int and float operands in arithmetic.
- ✓
The value of z is approximately 3.33 (type float).
Why this is correct
True division with `/` always yields a float in Python 3, so `10 / 3.0` produces the float `3.3333333333333335`, satisfying the stem's requirement that z be approximately 3.33. The float operand y reinforces this, and the result's type is float regardless of operand types.
- ✗
The type of w is int.
Why it's wrong here
Floor division with a float operand returns a float, so w is 3.0, type float, not int. It is tempting because floor division discards the fractional part, and with two integers (for example 10 // 3) the result genuinely is an int, which is the correct answer when both operands are ints.
- ✗
The expression x / y returns an integer.
Why it's wrong here
True division always returns a float in Python 3, so 10 / 3.0 gives 3.333..., a float, never an integer. It is tempting because in Python 2 integer operands made / perform floor division returning an int, which is the correct behaviour only under that legacy version.
- ✓
The value of w is 3.0.
Why this is correct
10 // 3.0 = 3.0.
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.