> For the complete documentation index, see [llms.txt](https://afsh4ck.gitbook.io/desarrollo-con-python/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://afsh4ck.gitbook.io/desarrollo-con-python/operadores-en-python/operadores/operadores-logicos.md).

# Operadores lógicos

Los operadores lógicos modifican y unen expresiones evaluadas en contexto booleano para crear condiciones más complejas.

| Operador | Ejemplo   | Significado                                                                                                                   |
| -------- | --------- | ----------------------------------------------------------------------------------------------------------------------------- |
| `not`    | `not x`   | <p><code>True</code> if <code>x</code> is <code>False</code><br><code>False</code> if <code>x</code> is <code>True</code></p> |
| `or`     | `x or y`  | <p><code>True</code> if either <code>x</code> or <code>y</code> is <code>True</code><br><code>False</code> otherwise</p>      |
| `and`    | `x and y` | <p><code>True</code> if both <code>x</code> and <code>y</code> are <code>True</code><br><code>False</code> otherwise</p>      |

## 1. Operador `not`

```python
num = 5

num < 10
True

not num < 10
False

not (num < 10)
False
```

## 2. Operador `or`

```python
num1 = 5
num2 = 10

num1 < 4
False

num1 < 4 or num2 > 5
True

(num1 < 4) or (num2 > 5)
True
```

## 3. Operador `and`

```python
num1 = 5
num2 = 10

num1 < 6 and num2 > 5
True

num1 < 4 and num2 > 5
False

(num1 < 5 or num2 > 3) and num2 == 10 and num1 < 8
True
```
