Skip to content

floor division

In Python, floor division is division that rounds the result down to the nearest whole number. The floor division operator is a double slash (//), which sets it apart from true division (/). You’ll want it whenever a whole-number answer is what your code actually needs, like splitting items into fixed-size batches or turning a duration into whole minutes.

Rounding down isn’t the same as chopping off the digits after the decimal point. Python rounds toward negative infinity, so 11 // 4 is 2 and -11 // 4 is -3 rather than -2.

The type of the result follows Python’s usual numeric rules. Floor-dividing two integers gives you an int, while mixing in a float gives you a float with a zero fractional part, such as 3.0. A zero divisor raises ZeroDivisionError, and floor division isn’t defined for complex numbers at all.

Floor division pairs with the modulo operator (%), which returns what’s left over. The two satisfy the identity x == (x // y) * y + x % y, and divmod() computes both halves in a single call.

Drag the dividend and divisor below to watch the true quotient snap down the number line to the integer at or below it, and notice how that differs from truncating toward zero once the result goes negative:

Interactive diagram — enable JavaScript to view.

Example

Say you’re formatting a duration given in seconds as minutes and seconds. Floor division gives you the whole minutes, and modulo gives you the seconds that don’t fill another minute:

Language: Python
>>> seconds = 754

>>> seconds // 60
12
>>> seconds % 60
34

>>> divmod(seconds, 60)
(12, 34)

>>> seconds / 60
12.566666666666666

True division reports the same quotient as 12.566..., which you’d have to round yourself before you could print it as a minute count. Floor division does that rounding as part of the operation, and divmod() collapses the two steps into one.

Operators and Expressions in Python

Tutorial

Operators and Expressions in Python

In Python, operators are special symbols, combinations of symbols, or keywords that designate some type of computation. You can combine objects and operators to build expressions that perform the actual computation. So, operators are the building blocks of expressions.

basics python

For additional information on related topics, take a look at the following resources:

Have a question about this? Mentor AI can show you examples, compare related terms, and point you to tutorials.


By Martin Breuss • Updated Sept. 15, 2026