Courseiva

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

Given the code: x = 10; y = 3.0; z = x / y; print(type(z)). What is the output?

⚠ Common exam trap

Python Institute often tests the distinction between / (true division) and // (floor division), trapping candidates who mistakenly think dividing an integer by a float returns an integer or that the result type depends on exact divisibility.

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

✓

<class 'float'>

In Python, when you divide an integer by a float using the / operator, the result is always a float. Here, x is an integer (10) and y is a float (3.0), so z = 10 / 3.0 evaluates to 3.3333333333333335, which is of type float. The print(type(z)) outputs <class 'float'>, making option B 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.

  • ✗

    <class 'str'>

    Why it's wrong here

    Dividing an int by a float produces a float, so type(z) is <class 'float'>, not str. String is tempting because print() displays text, but print converts the value for output; it does not change the object's type.

  • ✓

    <class 'float'>

    Why this is correct

    Dividing an integer by a float in Python always yields a float, because the true division operator promotes the result to the wider numeric type. Here 10 / 3.0 evaluates to 3.333..., so type(z) returns <class 'float'>, satisfying the stem's request for the printed type.

  • ✗

    <class 'complex'>

    Why it's wrong here

    Dividing an int by a float always yields a float in Python, so z is 3.333... and type(z) prints <class 'float'>. Complex results only arise when an operand is complex, such as 1j, or via complex() or cmath functions; no imaginary component exists here.

  • ✗

    <class 'int'>

    Why it's wrong here

    True division with a float operand always yields a float, so z is 3.333... and type() returns <class 'float'>. Integer is tempting because 10 looks whole, but Python 3's / operator never truncates, unlike floor division //.

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 →

How Courseiva writes practice questions · Editorial policy

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.