Courseiva

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

Which operator performs integer (floor) division in Python?

⚠ Common exam trap

Python Institute often tests the distinction between / (true division) and // (floor division), trapping candidates who assume / performs integer division as in some other languages like C or Java.

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 integer (floor) division in Python, which divides two numbers and returns the largest integer less than or equal to the result. For example, 7 // 2 returns 3, not 3.5, because it discards the fractional part and rounds down toward negative infinity for negative numbers.

Answer analysis

Option-by-option breakdown

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

  • ✓

    //

    Why this is correct

    The `//` operator performs floor division, dividing two numbers and rounding the result down to the nearest integer. For positive operands it discards the fractional part, satisfying the stem's requirement for integer division; unlike `/`, which always returns a float, `//` yields an integer when both operands are integers.

  • ✗

    %

    Why it's wrong here

    The percent sign returns the remainder of division (7 % 2 yields 1), not the floored quotient. It is tempting because it also relates to division and appears in the same operator family, and it would be the correct choice when the question asked for the modulo or remainder instead.

  • ✗

    /

    Why it's wrong here

    The forward slash performs true division, returning a float (7/2 yields 3.5), so it cannot produce the floored integer result the question demands. It is tempting because it is the everyday division operator, and it would be correct where fractional precision is wanted rather than an integer quotient.

  • ✗

    **

    Why it's wrong here

    The ** operator performs exponentiation, raising a number to a power, so it returns 8 for 2 ** 3 rather than the floor quotient. Floor division is performed by the // operator, which is the correct answer when a question asks for integer division discarding the remainder.

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.