...

/

Logical Operators

Logical Operators

Learn about logical operators with examples.

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
The four characters in our "Guess who?" game
The four characters in our "Guess who?" game

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
Who is wearing glasses?
Who is wearing glasses?

Negation (logical NOT)

Negation returns the ...