PCEP Computer Programming and Python Fundamentals Practice Question
A programmer writes: x = 5; y = 2; result = x / y. What is the type of result?
⚠ Common exam trap
Python Institute often tests the distinction between Python 3's true division (/) and floor division (//), trapping candidates who assume integer division returns an integer like in Python 2 or other languages such as C or Java.
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
✓
float
In Python 3, the division operator (/) always returns a floating-point number, even if both operands are integers. Since x and y are both integers (5 and 2), the result of 5 / 2 is 2.5, which is of type float. Therefore, option B is correct.
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
Why it's wrong here
In Python 3, the / operator always performs true division, so 5 / 2 yields the float 2.5, not an int. It is tempting because int matches the operands' types and would be correct for the // floor-division operator, which returns 2.
- ✓
float
Why this is correct
The division operator in Python 3 always performs true division, returning a float regardless of whether operands are integers. So 5 / 2 yields 2.5, typed as float, not int. Floor division (//) would return an integer instead.
- ✗
str
Why it's wrong here
Division of two ints never produces a str; / returns a numeric float (2.5) regardless of operand types. It is tempting because str is the result type of input() and of concatenation, so it would be correct if the code read values as text rather than dividing numbers.
- ✗
complex
Why it's wrong here
The / operator on two ints returns a float (2.5), never a complex; complex arises only from operations involving an imaginary literal such as 1j. It is tempting because complex is a genuine Python numeric type, and would be correct if the expression involved square roots of negative numbers.
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 →
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.