Boolean Logic

Boolean logic appears in the National Curriculum for Computing at KS3. It is also a key to understanding the truth tables and logic gates that appear in GCSE Computer Science.   Boolean logic is named after George Boole, and describes a way of combining "truth values" in calculations. Truth values are best thought of as true or false, but can also be thought of as any pair of opposites, e.g. yes/no, on/off, or 1/0, where true = yes = on = 1 and false = no = off = 0.

Below you can toggle a switch by clicking, and you can select a Boolean operator from the list. Try operating both switches to see how AND, OR, EOR and NOT work. For a detailed description, or to see truth tables, see the Boolean Logic page in the Mathematics section.


Unfortunately the interactive part of this page requires a wider screen. If you are using a mobile device you could try changing the orientation to landscape.

The result of an AND is only true (i.e. the bulb only lights) if both switches are on, and the result of an OR is true if either switch OR the other is on. EOR is short for exclusive OR (sometimes also written as XOR) and means "one or the other but not both" - i.e. the output is only true if the switches aren't in the same position.

Notice that NOT only has one input - the state of the bulb is the opposite of the state of the switch.  This is known as a unary operator and is a bit like the use of - in arithmetic to indicate negative numbers.

There is also a page on logic circuits in this section. For a more in-depth discussion of this and other similar techniques, including truth tables, look at the Boolean Logic page in the Mathematics section.  You might also find Python programs using Boolean logic on the programming example page.