> ## 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 Logical NOT

The `not` operator is a unary logical operator that performs boolean negation. It evaluates the truthiness of a single operand and returns the inverted boolean value: `True` if the operand is considered false, and `False` if the operand is considered true.

```python theme={"dark"}
not expression
```

## Evaluation Mechanics

Unlike Python's `and` and `or` operators, which can return the operands themselves, the `not` operator strictly guarantees a return type of `bool`. It forces the operand into a boolean context using Python's internal truth value testing.

1. **Truthiness:** If the operand evaluates to `True` (truthy), `not` returns `False`.
2. **Falsiness:** If the operand evaluates to `False` (falsy), `not` returns `True`.

In Python, the following standard values are inherently falsy:

* Constants defined to be false: `None` and `False`.
* Zero of any numeric type: `0`, `0.0`, `0j`, `Decimal(0)`, `Fraction(0, 1)`.
* Empty sequences and collections: `''`, `()`, `[]`, `{}`, `set()`, `range(0)`.

All other values are considered truthy by default.

```python theme={"dark"}

# Standard boolean negation
print(not True)   # False
print(not False)  # True


# Negation of falsy objects
print(not None)   # True
print(not 0)      # True
print(not [])     # True


# Negation of truthy objects
print(not 1)      # False
print(not "Data") # False
print(not [1, 2]) # False
```

## Object-Level Implementation

Under the hood, `not x` is evaluated by calling `bool(x)` and inverting the result. The `bool()` built-in determines truthiness by looking for specific magic methods (dunder methods) on the object's class:

1. Python first checks for the `__bool__()` method. If it exists, `not` returns the inverse of what `__bool__()` returns.
2. If `__bool__()` is not defined, Python falls back to `__len__()`. If `__len__()` returns `0`, the object is falsy (so `not` returns `True`). If it returns a non-zero integer, the object is truthy (so `not` returns `False`).
3. If neither method is defined, the object is considered truthy by default, and `not` will return `False`.

## Operator Precedence

The `not` operator has a lower precedence than non-boolean operators (like arithmetic, bitwise, and comparison operators) but a higher precedence than the logical operators `and` and `or`.

```python theme={"dark"}

# Evaluated as: not (5 > 2)
not 5 > 2  # False


# Evaluated as: (not True) and False
not True and False  # False
```

<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>
