Courseiva

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

What is the output of the following code? ```python x = 10 y = 3

print(x // y * y + x % y)

```

⚠ Common exam trap

Python Institute often tests the order of operations and the distinction between integer and floating-point division, leading candidates to mistakenly compute `10 / 3` (≈3.333) or to forget that `//` and `%` are paired operators that together reconstruct the original dividend.

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

The expression `x // y * y + x % y` is evaluated using integer arithmetic. First, `x // y` is floor division: 10 // 3 = 3. Then `3 * y` = 3 * 3 = 9. Then `x % y` = 10 % 3 = 1. Finally, 9 + 1 = 10, which is an integer. Option C is correct because the result is 10 (type int).

Answer analysis

Option-by-option breakdown

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

  • ✗

    9

    Why it's wrong here

    Integer division 10 // 3 gives 3, times 3 is 9, plus 10 % 3 which is 1, totalling 10. The option 9 tempts because it captures the floor-division product alone and omits the remainder term, which the expression adds back.

  • ✗

    10.0

    Why it's wrong here

    Integer floor division and modulo both return ints here, so the expression evaluates to 9, an int, not a float. Python does not promote the result to float merely because division appears; floats arise only when an operand is a float, which none is.

  • ✓

    10

    Why this is correct

    Floor division and modulo recombine the original dividend: 10 // 3 gives 3, and 10 % 3 gives 1. Multiplying 3 by 3 yields 9, then adding the remainder 1 returns 10, satisfying the identity x == (x // y) * y + x % y.

  • ✗

    9.0

    Why it's wrong here

    The expression yields the int 10, not 9.0; both // and % on ints produce ints, and adding them keeps the int type. A float result would require a float operand, which this code does not contain.

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.