> ## Documentation Index
> Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Python Floor Division Assignment

The `//=` operator is the augmented assignment operator for floor division. It divides the left operand by the right operand, applies the floor function to the quotient (rounding down towards negative infinity), and assigns the resulting value back to the left operand.

```python theme={"dark"}
x //= y
```

While conceptually similar to the expanded assignment `x = x // y`, augmented assignment evaluates the left-hand side expression exactly once. This is a critical distinction when the left operand involves a function call, property access, or complex indexing:

```python theme={"dark"}

# get_index() is executed only once
items[get_index()] //= 2


# get_index() is executed twice
items[get_index()] = items[get_index()] // 2
```

## Technical Mechanics

**Type Coercion and Return Types**
The data type of the resulting assignment depends on the types of the operands involved:

* If both operands are integers (`int`), the result assigned to the left operand is an `int`.
* If either operand is a floating-point number (`float`), the result assigned to the left operand is a `float` representing a whole number.

**Rounding Direction**
Unlike truncation (which rounds towards zero), Python's floor division strictly rounds towards negative infinity. This distinction is critical when evaluating negative numbers. For example, `-10 / 3` evaluates to `-3.333...`. Applying the floor function rounds this down to `-4`, not `-3`.

**Zero Division**
If the right operand evaluates to zero (e.g., `x //= 0` or `x //= 0.0`), Python raises a `ZeroDivisionError`. This semantic rule applies universally to all division-based operators in Python.

**Object Model Implementation**
When the Python interpreter encounters `x //= y`, it resolves the operation through the following sequence:

1. It attempts to invoke the in-place magic method `__ifloordiv__(self, other)` on the left operand. If implemented (typically by mutable custom types), the operation modifies the object in-place and returns it.
2. If `__ifloordiv__` is not implemented, Python falls back to the standard floor division method `__floordiv__(self, other)` and binds the resulting new object back to the target variable name.

*Note: Built-in immutable numeric types like `int` and `float` do not implement `__ifloordiv__` at all. They rely entirely on the `__floordiv__` fallback, meaning a new numeric object is always allocated and reassigned to the variable.*

## Evaluation Examples

```python theme={"dark"}

# Integer evaluation
a = 10
a //= 3
print(a)  # Output: 3
print(type(a))  # Output: <class 'int'>


# Floating-point evaluation
b = 10.0
b //= 3
print(b)  # Output: 3.0
print(type(b))  # Output: <class 'float'>


# Negative operand evaluation (rounding towards negative infinity)
c = -10
c //= 3
print(c)  # Output: -4


# Zero division exception
d = 5
d //= 0  # Raises ZeroDivisionError: integer division or modulo by zero
```

<div
  style={{ 
display: "flex", 
justifyContent: "space-between", 
alignItems: "center", 
maxWidth: "754px", 
padding: "1rem 0",
marginBottom: "24px"
}}
>
  <span style={{ fontWeight: "bold", fontSize: "1.25rem", color: "var(--tw-prose-headings)", fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif" }}>Tired of Poor Python Skills? Fix That With Deep Grasping!</span>

  <a
    href="https://syntblaze.com"
    target="_blank"
    style={{ 
  marginLeft: "24px",
  textDecoration: "none", 
  backgroundColor: "#007AFF",
  color: "#ffffff", 
  padding: "6px 16px", 
  borderRadius: "16px",
  fontSize: "0.9rem",
  fontWeight: "600",
  textAlign: "center",
  transition: "background-color 0.2s ease"
}}
  >
    Learn More
  </a>
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/skill-tracking.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=b9b0305c93bb501c9e767b5c76c88835" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/skill-tracking.png" />

  <img src="https://mintcdn.com/syntblazellc/23tyuOzaWS88qFlc/images/nuggets.png?fit=max&auto=format&n=23tyuOzaWS88qFlc&q=85&s=c86c80197299762989e9b882419b2109" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/nuggets.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/bite-sized-exercises.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=a65f9a38c37ff28ab73ed783c53c60e3" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/bite-sized-exercises.png" />
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap", marginTop: "12px" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/mastery-chain.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=748a1763454713e679260fbb95f154a2" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/mastery-chain.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-previews.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=242f61448ff5dd6deaaab2dccc13b507" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-previews.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-explanations.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=cf0fc1c31f9cd0fc26716781be05fbc9" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-explanations.png" />
</div>
