Courseiva

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

What is the type of the result of the expression 5 + 3.0?

⚠ Common exam trap

The PCEP exam often tests the misconception that adding an integer and a float returns an integer, or that Python truncates the result, when in fact Python always promotes to the more precise type (float).

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, when an integer (int) and a float are combined using the addition operator, the result is implicitly converted to a float to preserve precision. Since 3.0 is a float, 5 + 3.0 yields 8.0, which is of type 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.

  • ✗

    str

    Why it's wrong here

    Adding an int and a float yields a float in Python, so the result is 3.0's type, not str. The option is tempting because the expression mixes numeric literals and beginners may expect text output, but numeric addition never produces a string.

  • ✓

    float

    Why this is correct

    Adding an int and a float triggers Python's implicit numeric promotion: the int operand is converted to float before addition, so the result always takes the wider type. Here 5 becomes 5.0, and 5.0 + 3.0 yields 8.0, a float, satisfying the expression's mixed-type operand constraint.

  • ✗

    int

    Why it's wrong here

    Python widens int to float when operands mix, so 5 + 3.0 produces 8.0, not an int; no truncation occurs. It tempts because int is the type of the first operand, and int would be correct only if both operands were integers, as in 5 + 3.

  • ✗

    complex

    Why it's wrong here

    Adding an int and a float yields a float in Python; complex requires an imaginary component (a j suffix), which neither operand supplies. It tempts because complex is a genuine numeric type, and it would be the result only if an operand were written as, say, 3j.

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.