PCEP Practice Question: Data Types, Variables, Basic I/O and Operators
Exhibit
Refer to the exhibit. Command output: >>> 5 // 2 2 >>> 5 % 2 1 >>> 5 / 2 2.5
Based on the exhibit, which expression returns 2.5 in Python?
⚠ Common exam trap
Python Institute often tests the distinction between `/` (true division returning float) and `//` (floor division returning integer), trapping candidates who confuse the two or expect integer division from `/` as in Python 2.
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
✓
5 / 2
The division operator `/` in Python always returns a float, even when dividing two integers. Since 5 divided by 2 equals 2.5, the expression `5 / 2` returns the float `2.5`.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
int(5 / 2)
Why it's wrong here
int() truncates the float 2.5 to the integer 2, discarding the fractional part. Casting to int is correct when you deliberately need whole-number results, for example converting a computed average into a count of complete items.
- ✗
5 % 2
Why it's wrong here
The modulo operator returns the remainder of integer division, so 5 % 2 yields 1, an integer, not 2.5. Modulo is the right tool when you need divisibility checks or cyclic wrapping, such as determining whether a number is even.
- ✗
5 // 2
Why it's wrong here
Floor division discards the fractional part, so 5 // 2 evaluates to 2, not 2.5. It is tempting because // is Python's integer-division operator, and it would be the right choice when you deliberately need a whole-number quotient, such as splitting items into equal whole groups.
- ✓
5 / 2
Why this is correct
Python 3's division operator always performs true division on integers, so 5 / 2 yields the float 2.5 rather than the floored integer 2. Floor division (//) would return 2, and integer operands do not otherwise produce a float result.
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.