Operators

// — Floor division

For integers returns the quotient rounded toward negative infinity. Float operands yield a float representing a floored quotient, subject to floating-point limitations; complex operands are unsupported. Division by zero raises ZeroDivisionError. For integers, a == (a // b)*b + a%b when b is nonzero. Custom numeric types may define different behavior via __floordiv__ and __rfloordiv__; do not assume every third-party type uses integer floor semantics.

Formal Syntax & Structure

python syntaxpython
left // right

Parameters & Attributes

NameTypeDescription
leftreal number or supporting objectReal numeric dividend or custom object.
rightreal number or supporting objectNonzero real numeric divisor or custom object.

Return Value

number or custom result

Numeric result for supported built-in numbers; custom methods can return other objects.

Working Example

Example Snippetpython
print(7 // 3)print(-7 // 3)print(7 // -3)print(7.0 // 3)
Python Reference