MyLeoNes™

Boolean logic: combining yes and no — Computing, 7–10

Computers often decide by combining answers that are either true or false. You can build these decisions with AND, OR and NOT.

Idea

Boolean logic is a way to combine answers that have only two possible states: true or false, on or off. AND means both answers must be true, OR means at least one must be true, and NOT flips an answer. These tiny rules let a program make precise choices.

Why it exists

A computer cannot act on a vague thought such as “go outside when it feels nice”. It needs small tests whose answers can be checked, then a rule for joining them. For example, a game might open a door only when you have the key AND you are standing beside it. Boolean logic turns messy situations into instructions a machine can test.

Worked example

A robot waters a plant when the soil is dry AND the water tank is not empty. Step 1: dry soil gives true. Step 2: a tank with water gives true for “not empty”. Step 3: true AND true is true, so the robot waters. If the soil is wet, the first answer is false; false AND true is false, so it waits.

A common trap

A reasonable mistake is treating OR as if it meant both things must happen. In ordinary speech, “bring a coat or an umbrella” can sound like a choice, but in a computer OR usually means one, the other, or both. So if a game says “red OR blue”, a purple object may pass because it has both colours.

Outside school

Boolean logic is behind everyday checks: a phone may unlock when your face is recognised AND the screen is awake. A shopping site can show items that are cheap OR on sale, while a game can give a bonus when several conditions match. Whenever a machine combines yes-or-no tests, these rules are close by.

Keep exploring

Other languages

Loading MyLeoNes™…