Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / Python

Operator //=

Divides the stored value and writes the quotient rounded toward negative infinity back to the target.

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

Syntax

target //= value

Divides the stored value and writes the quotient rounded toward negative infinity back to the target.

Use this update to replace a signed position with its bucket index. With integer operands the stored quotient is also an integer.

The result is rounded toward negative infinity. If either operand is floating point the stored result can be a float, and a zero divisor raises a division exception.

The updated integer contains the floor of the quotient, including for a negative dividend.

Syntax

target //= value

__ifloordiv__, __floordiv__, __rfloordiv__ · ZeroDivisionError

Worked example

n = -7; n //= 2
n → -4
type(n) is int → True
n = -7; n //= -2
n → 3

Examples

value = -19
value //= 4
print(value)
print(type(value).__name__)

Result

-5
int

The updated integer contains the floor of the quotient, including for a negative dividend.

Sources