PCEP Practice Question: Data Types, Variables, Basic I/O and Operators
A developer writes the following code: x = 5; y = 2; print(x // y). What is the output?
⚠ Common exam trap
Python Institute often tests the distinction between floor division (//) and true division (/), trapping candidates who confuse the two operators or forget that integer operands produce an integer result with //.
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
✓
2
The floor division operator (//) in Python returns the largest integer less than or equal to the result of the division. Since 5 divided by 2 equals 2.5, the floor is 2, and the result is an integer (int) because both operands are integers. Therefore, the output is 2.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
1
Why it's wrong here
Floor division of 5 by 2 yields 2, not 1. The value 1 corresponds to the modulo operation (5 % 2), which returns the remainder; // returns the quotient rounded down toward negative infinity, so the integer result here is 2.
- ✓
2
Why this is correct
The // operator performs floor division, dividing 5 by 2 and rounding the result down to the nearest integer. Since both operands are integers, Python returns an int, and 2.5 floors to 2, matching the printed output.
- ✗
2.0
Why it's wrong here
Floor division of two integers returns an int in Python 3, so the output is 2, not 2.0. The float 2.0 arises from true division (5 / 2); // discards the fractional part and preserves integer type when both operands are ints.
- ✗
2.5
Why it's wrong here
2.5 is the result of true division (5 / 2), which returns a float. The // operator performs floor division, discarding the fractional remainder and returning the integer 2; the decimal expansion never appears in the output.
Go deeper
Related to this question
About these practice questions
Courseiva writes every PCEP question from scratch — 482 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
Same concept, more angles
2 more ways this is tested on PCEP
These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.
Variation 1. What is the output of the code in the exhibit?
medium- ✓ A.3
- B.4
- C.3.0
- D.3.3333333333333335
Why A: The code performs integer division using the // operator, which in Python returns the floor of the division result for positive numbers. Since 10 // 3 equals 3 (the integer part of 10/3), the output is 3. Option A is correct because integer division discards the fractional part.
Variation 2. Given the exhibit, what does the code print?
hard- ✓ A.3.0
- B.3
- C.3.5
- D.3.5
Why A: The code likely performs floor division with at least one float operand (e.g., print(7.0 // 2) or print(7 // 2.0)). Floor division // returns the largest integer less than or equal to the quotient, but if either operand is a float, the result is a float. Since 7.0 // 2 = 3.0, the output is 3.0. If both operands were integers, the result would be the integer 3, not 3.0. Thus option A (3.0) is correct.
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.