Skip to content
BENIBIX Learn

Logical Operator

Development🧩 Programming ConceptsData and Variables

Also known as Boolean Operator, AND OR NOT

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

Think of it like

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

Example

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

Why it matters

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

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 code

python
>>> age = 15
>>> age >= 13 and age < 18
True
>>> not True
False
Both tests pass, so and gives True. Not flips the value.

Common mistake

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

Key takeaways

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

Learn it properly