Logical Operators

Logical operators are used to combine or modify conditions

A logical operator is a symbol used to perform logical operators. They combine or invert TRUE and FALSE conditions.

AND, OR and NOT are the three common operators.

AND

AND Operator

The AND operator checks if both conditions are true. The result is true only if both conditions are true.

AND Operator purpose

The AND operator is used to check if two conditions are both true.

Example
“The password must contain a number AND a special character to be valid.”

Condition A Condition B A AND B
True True True
True False False
False True False
False False False

OR

OR Operator

The OR operator checks if either input is true. If any of the the inputs are true then the output is also true.

OR Operator purpose

The OR operator is used to ensure at least one input is true.

Example
“The user can pick either red OR blue, if so they can proceed.”

Condition A Condition B A AND B
True True True
True False True
False True True
False False False

NOT

NOT Operator

The NOT operator reverses a condition.

  • If a condition is true, NOT makes it false.
  • If a condition is false, NOT makes it true.

NOT operator purpose

The NOT operator is used to reverse a condition.

Example
“Show all results NOT containing the word ‘Glasgow’.”

Condition A NOT A
True False
False True

Targets

State the purpose of the AND operator

State the purpose of the NOT operator

State the purpose of an OR truth table

State the output of an AND truth table

State the output of a NOT truth table

State the output of an OR truth table