Courseiva

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

A script uses the // operator with negative numbers. For example, -7 // 2 returns -4. The developer expected -3. Which statement best explains this behavior?

⚠ Common exam trap

Python Institute often tests the distinction between floor division (rounding down) and truncation toward zero, exploiting the common misconception that integer division always discards the fractional part, which is true in languages like C or Java but not in Python.

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

✓

The // operator performs floor division, which rounds down to the next lower integer.

In Python, the // operator performs floor division, which always rounds down to the next lower integer (toward negative infinity). For -7 // 2, the exact result is -3.5, and floor division rounds down to -4, not -3. This behavior is defined by the Python language specification and differs from truncation toward zero.

Answer analysis

Option-by-option breakdown

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

  • ✗

    The // operator uses banker's rounding.

    Why it's wrong here

    Banker's rounding applies to round(), not floor division; // returns the floor, the largest integer not exceeding the true quotient, giving -4. The phrase is tempting because rounding to even is a real Python behaviour, but it governs round() of ties, not the // operator's result.

  • ✗

    The // operator truncates toward zero for negative numbers.

    Why it's wrong here

    Truncation toward zero would yield -3, which is exactly the result the developer expected, so it cannot explain the -4 output. The idea is tempting because C and Java integer division truncates, but Python's // floors instead, producing -4 for -7 // 2.

  • ✗

    The // operator performs integer division with rounding to the nearest even integer.

    Why it's wrong here

    Rounding to the nearest even integer would give -4 only coincidentally; // actually floors, returning the largest integer not exceeding the quotient. Nearest-even rounding is tempting because Python's round() uses it, but that applies to round(), not to the floor division operator.

  • ✓

    The // operator performs floor division, which rounds down to the next lower integer.

    Why this is correct

    Floor division returns the largest integer less than or equal to the true quotient. For -7 // 2, the exact quotient is -3.5, and flooring gives -4, not truncation toward zero, which would yield -3.

About these practice questions

Courseiva writes every PCEP question from scratch — 482 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or 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.