Courseiva

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

What is the output of print(type(3 + 4.5))?

⚠ Common exam trap

Python Institute often tests the misconception that integer + float yields an integer, or that the type() function returns the string 'int' or 'float' rather than the actual class object.

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 add an integer (3) and a float (4.5), implicit type conversion (coercion) occurs: the integer is promoted to a float to avoid data loss. The result is 7.5, which is a float. Therefore, type(7.5) returns <class 'float'>.

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 'int'>

    Why it's wrong here

    Adding an int and a float triggers Python's numeric coercion, producing a float, so the type is <class 'float'>. The int result appears only when both operands are integers, such as 3 + 4, which is the case this option describes.

  • ✗

    <class 'complex'>

    Why it's wrong here

    Complex numbers require an explicit imaginary literal such as 3j; 4.5 is a plain float, so the result is a float, not complex. Complex is tempting because it is a genuine numeric type Python returns for imaginary arithmetic, but no imaginary component exists here.

  • ✓

    <class 'float'>

    Why this is correct

    Adding an int and a float triggers Python's implicit numeric promotion, converting the integer operand to float before addition. The result, 7.5, is therefore a float object, and type() returns <class 'float'>. This satisfies the stem's requirement to identify the exact type of the mixed-type arithmetic expression.

  • ✗

    <class 'str'>

    Why it's wrong here

    Adding an int to a float yields a float, so the type is <class 'float'>, never str. Strings arise only from concatenation or quoting, which makes this tempting when learners confuse printed output with type. No string conversion occurs in the expression 3 + 4.5.

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

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.