Courseiva

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

Which TWO of the following expressions produce the integer 5?

⚠ Common exam trap

Python Institute often tests the distinction between `/` (true division returning float) and `//` (floor division returning int), as well as the difference between numeric types (int vs. float vs. string), to catch candidates who overlook Python's implicit type conversions.

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

✓

10 // 2

Option B, 10 // 2, is correct because the // operator performs floor division on integers, and 10 divided by 2 yields exactly 5 as an int. Option C, int(5.7), is correct because int() truncates the float toward zero, discarding the fractional part .7 and returning the integer 5. Option A, "5", is a string literal, not an integer, so it does not produce the integer 5. Option D, 5.0, is a floating-point value, not an int. Option E, 10 / 2, uses true division, which in Python 3 returns the float 5.0 rather than the integer 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.

  • ✗

    "5"

    Why it's wrong here

    "5" is a string literal containing the character five, so its type is str, not int. It is tempting because it displays as 5. A string is correct where text is required, such as reading user input or concatenating values, not for integer arithmetic.

  • ✓

    10 // 2

    Why this is correct

    The floor division operator // divides and rounds down to the nearest integer, so 10 // 2 evaluates to the integer 5, not the float 5.0. This satisfies the stem's requirement of producing the integer 5, unlike true division / which would return 5.0.

  • ✓

    int(5.7)

    Why this is correct

    The int() constructor truncates toward zero when converting a float, discarding the fractional part. Applied to 5.7, it returns the integer 5, satisfying the stem's requirement of producing the integer 5. Note this differs from rounding, which would yield 6.

  • ✗

    5.0

    Why it's wrong here

    5.0 is a float literal, so its type is float, not int, regardless of the displayed value. It is tempting because the numeric value equals five. A float would be the correct choice where fractional precision or floating-point arithmetic is required, such as scientific calculations.

  • ✗

    10 / 2

    Why it's wrong here

    In Python 3, / performs true division, so 10 / 2 evaluates to the float 5.0, not the integer 5. It is tempting because the quotient is a whole number. Floor division with // would be correct when an integer result is required.

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 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.