Boolean logic: combining true and false — Computing, 11–13 years
Boolean logic gives programs a precise way to combine yes-or-no facts, so several conditions can guide one decision.
Questions with two answers
A Boolean value has only two possible answers: true or false, yes or no. Programs use these answers for facts such as “the door is open” or “the score is greater than 10”. AND, OR and NOT combine or change those facts.
Why combine conditions
Real decisions often depend on more than one fact. A game might open a gate only when a player has a key AND enough points, or accept a player who has a pass OR is on the guest list. Boolean logic turns such rules into exact instructions instead of vague guesses.
Checking a game gate
The rule is: open if hasKey AND score is at least 10. Ana has a key, so hasKey is true. Her score is 12, so the second fact is true. True AND true gives true, and the gate opens; with a score of 7, it would stay closed.
AND is not OR
People often read AND as “one of these is enough”, because ordinary speech can be loose. In code, AND demands that every joined condition is true. OR needs only one true condition. Writing the wrong connector can make a safe rule too strict or let the wrong person through.
Rules in real systems
A phone may unlock when the face matches AND the correct passcode is entered. An online shop may show a warning when an item is fragile OR delivery is far away. These checks are useful because machines need a clear way to combine small facts before acting.
Keep exploring
Other languages
Loading MyLeoNes™…