Boolean Logic

This interactive page allows you to visualise and experiment with operators in Boolean Logic.  Boolean Logic appears in the National Curriculum for Computing at KS3 and in GCSE Computer Science courses. It is also a key to understanding the truth tables and logic circuits that appear in more advanced courses and are a useful programming technique.  

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 experiment and test your understanding of Boolean Logic.  Click on a switch to toggle it on or off, and select a Boolean operator from the list in the middle. Toggle 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.

=

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 in the programming examples.