PCEP Practice Question: Data Types, Variables, Basic I/O and Operators
A programmer writes the following code: `x = 7` then `y = 2` then `z = x / y`. What is the data type and value of `z`?
⚠ Common exam trap
The trap here is assuming that division of two integers returns an integer, perhaps due to experience with other programming languages or 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
✓
`float` with value `3.5`
In Python 3, the division operator `/` always returns a float, even when dividing two integers that yield a whole number. For `x = 7` and `y = 2`, the result is `3.5`, stored as a `float`. This behavior differs from Python 2, where `/` performed integer division for integers. The `//` operator performs floor division and returns an integer when both operands are integers, but that is not used here.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
`float` with value `3.5`
Why this is correct
In Python 3, the `/` operator performs true division and always returns a `float`, regardless of operand types. With `x = 7` and `y = 2`, the result is `3.5`, a floating-point number. This is a key difference from Python 2, where integer division with `/` would yield an integer. Here, the type is `float` and the value is `3.5`.
- ✗
`int` with value `4`
Why it's wrong here
This option suggests rounding to the nearest integer, but Python's `/` does not round. It returns the exact floating-point result. Also, the type would be `float`, not `int`. Rounding would require a function like `round()`, and even then the type would remain `float` unless explicitly converted. Here, `7 / 2` evaluates to `3.5` as a float.
- ✗
`int` with value `3`
Why it's wrong here
This option assumes that division of two integers yields an integer, truncating the decimal part. In Python 3, the `/` operator always returns a float, even when both operands are integers and the result is a whole number. The value `3.5` is not truncated, and the type is `float`, not `int`.
- ✗
`float` with value `3.0`
Why it's wrong here
This option recognizes that the result is a float but incorrectly assumes the fractional part is discarded. Python's `/` operator does not truncate; it computes the exact quotient. For `7 / 2`, the exact quotient is `3.5`, not `3.0`. Truncation would require the `//` operator, which performs floor division and would yield `3` (an integer if both operands are integers).
Go deeper
Related to this question
About these practice questions
This PCEP question is part of Courseiva's 482-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official Python Institute exam blueprint
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.