Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / Python

Operator //

Rounds the quotient down to the nearest integer at or below its value.

Version: Python 3.14; repository image, production runtime not attested

Syntax

left // right

Rounds the quotient down to the nearest integer at or below its value.

For integers, floor division gives the bucket number when sorting signed coordinates into equal-width intervals. An integer dividend divided by an integer divisor produces an integer.

A floating-point operand can produce a float representing a whole number. The floor quotient pairs with the remainder to reconstruct the dividend in exact integer arithmetic. A zero divisor raises an exception.

A negative quotient rounds toward negative infinity, which can differ from truncation toward zero.

Syntax

left // right

__floordiv__, __rfloordiv__ · ZeroDivisionError

Worked example

-7 // 2 → -4
7.0 // 2 → 3.0
7 // 0 → ZeroDivisionError

Examples

print(19 // 4)
print(-19 // 4)

Result

4
-5

A negative quotient rounds toward negative infinity, which can differ from truncation toward zero.

Sources