# Logical Operator

> The words and, or and not, which join or flip true and false values.

**Field:** Software Development  
**Category:** Programming Concepts  
**Also known as:** Boolean Operator, AND OR NOT

## Think of it like

Think of it like a rule to go out and play. You need your shoes and your coat.

## Definition

A logical operator joins or flips true and false values. and is true only when both sides are true. or is true when at least one side is true. not turns true into false and false into true. Some languages write these as &&, || and ! instead of words.

## Example

A ride lets people on if height >= 120 and age >= 8. Jack is tall enough but only 7, so the answer is False.

## Example code

```python
>>> age = 15
>>> age >= 13 and age < 18
True
>>> not True
False
```

Both tests pass, so and gives True. Not flips the value.

## Why it matters

Real rules have more than one part. Logical operators let one if check them all at once.

## Common mistake

Mixing up and and or. Or lets in anyone who passes one test, which is often far too many.

## Three principles

- **And needs both.** True only when every side is true.
- **Or needs one.** True when any side is true.
- **Not flips.** It turns true into false.

## Related terms

- [Operator](https://learn.benibix.com/term/development/operator)
- [Boolean](https://learn.benibix.com/term/development/boolean)
- [Comparison Operator](https://learn.benibix.com/term/development/comparison-operator)
- [Conditional Statement](https://learn.benibix.com/term/development/conditional-statement)

## Taught in

- [Operators in Python](https://learn.benibix.com/learn/development-concepts/operators-in-python): Programming Basics, 9/18

---

Source: https://learn.benibix.com/term/development/logical-operator
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
