TutreNews Learn

Boolean logic

AND, OR, NOT, XOR

Goal: Fill truth tables for the basic operators · 9 min

Boolean logic works with only two values: true (1) and false (0). Four operators build everything:

ABA AND BA OR BA XOR BNOT A
000001
010111
100110
111100
  • AND: true only if both are true.
  • OR: true if at least one is true (also both!).
  • XOR (exclusive or): true if exactly one is true.
  • NOT: flips the value.

In code: AND = &&, OR = ||, NOT = ! (JavaScript); and, or, not (Python). In hardware these are logic gates built from transistors.

Worked example: A door alarm

  1. Alarm if the system is armed AND (door open OR window open).
  2. Armed = 1, door = 0, window = 1 → 0 OR 1 = 1.
  3. 1 AND 1 = 1 → the alarm sounds.