Logical Operators
Learn about logical operators with examples.
We'll cover the following...
Logical operators can be used to combine two or more statements to produce a compound statement that returns a Boolean value.
Guess who?
“Guess who?” is a popular family game that involves trying to guess a person by asking “yes” or “no” questions about their appearance. We’re going to consider a smaller version of the game to demonstrate some logical operators.
Our smaller game only has four characters: Alfie, Betty, Gemma and Del.
Press + to interact
Each character has two particular characteristics: they either wear a hat or they don’t, and they either wear glasses or they don’t.
For example, if we asked “Who is wearing glasses?”, the answer would be “Betty and Del”.
Press + to interact
Negation (logical NOT)
Negation returns the ...