Courseiva

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

A developer is inspecting a variable and writes: value = 7.0 // 2. What is the value and type of the result assigned to 'value'?

⚠ Common exam trap

The trap here is assuming // always returns an int, when in fact it returns a float if either operand is a 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

✓

3.0, of type float

Floor division // computes the quotient and rounds down to the nearest whole number, and the result is a float whenever either operand is a float. With 7.0 // 2, the quotient 3.5 floors to 3.0 and remains a float. The int result appears only when both operands are ints, and plain division would leave 3.5.

Answer analysis

Option-by-option breakdown

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

  • ✗

    3.5, of type float

    Why it's wrong here

    3.5 is the result of true division using /, not floor division using //. The // operator discards the fractional part by flooring, so 3.5 becomes 3.0. Choosing this reflects confusion between / and //, which is a common mistake when reading expressions quickly.

  • ✗

    3, of type int

    Why it's wrong here

    This would be the result if both operands were integers, because int // int yields an int. Here the left operand is 7.0, a float, so the result type is float even though the value is a whole number. The scenario specifically uses 7.0, so the type must be float.

  • ✗

    4.0, of type float

    Why it's wrong here

    4.0 would result from rounding up, but // always floors toward negative infinity, not toward the nearest integer. For positive values floor and truncation coincide, and 7.0 divided by 2 is 3.5, which floors to 3.0. The operator never rounds up for positive operands.

  • ✓

    3.0, of type float

    Why this is correct

    The floor division operator // divides and rounds down to the nearest integer value, but when either operand is a float the result is a float. 7.0 // 2 computes 3.5 and floors it to 3.0, keeping the float type. This is correct because // preserves float type when any operand is a float.

About these practice questions

One of 482 original PCEP practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

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.