Courseiva

PCEP Practice Question: Data Types, Variables, Basic I/O and Operators

Exhibit

Refer to the exhibit.

x = 10
y = 3.0
z = x * y
print(z)

What is the data type of z after executing z = 10 / 2?

⚠ Common exam trap

Python Institute often tests the distinction between / (true division, returns float) and // (floor division, returns int) to catch candidates who assume integer division returns an integer.

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

Float because in Python, the / operator always performs true division and returns a float, regardless of the operands. This is a fundamental concept tested in the PCEP exam to distinguish between / and //.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    bool

    Why it's wrong here

    The / operator always returns a float in Python 3, so z = 10 / 2 yields 5.0, a float, not a bool. bool is tempting because comparisons and truth tests produce True or False, but division never returns that type.

  • ✗

    int

    Why it's wrong here

    True division with / produces a float even when the result is whole, so z = 10 / 2 gives 5.0, not int. int is tempting because floor division // returns an integer, but the stem uses the single-slash operator.

  • ✓

    float

    Why this is correct

    The division operator always returns a float in Python 3, even when both operands are integers and divide evenly. So 10 / 2 yields 5.0, a float, not an int. This satisfies the question's requirement to identify the resulting data type.

  • ✗

    str

    Why it's wrong here

    Division with / always yields a float in Python 3, so z is 5.0, not a string. str is tempting because text types hold characters, and it would be correct if the code called str() or used input(), which returns strings.

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 →

How Courseiva writes practice questions · Editorial policy

Same concept, more angles

1 more way 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. A developer writes: a = 3; b = 4; c = a + b / 2. What is the value of c?

hard
  • A.3
  • B.3.5
  • C.5
  • ✓ D.5.0

Why D: In Python, the division operator `/` always returns a float, and operator precedence dictates that division is performed before addition. Thus, `b / 2` evaluates to `4 / 2 = 2.0`, then `a + 2.0` yields `3 + 2.0 = 5.0`. Option D is correct because the result is a float value of 5.0.

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.