Chapter 2: Logical operators

Boolean logic

face Josiah Wang

For those not familiar with boolean logic:

  • A or B or C is True if at least one of A, B or C is True. It is False otherwise.
  • A and B and C is True only if all A, B and C are True. It is False otherwise.
  • not A will always return the inverse of A

Let’s see whether you understand what you have read above.

I have included some explanations in the quiz questions, so do read them whether or not you answered the questions correctly!

1 2 3 4 5 6 7 8 9 10

Question 1

What is the value of the following expression?

True and False

False

Question 2

What is the value of the following expression?

False or True

True

Question 3

What is the value of the following expression?

True or True or False

True
Explanation:

At least one operand is True.

Question 4

What is the value of the following expression?

False and False and False

False
Explanation:

All operands are False.

Question 5

What is the value of the following expression?

not False

True

Question 6

What is the value of the following expression?

not not not False

True
Explanation:

If you find this expression confusing, interpret it as a composition:

  • not (not (not False))
  • not (not True)
  • not False
  • True

Question 7

What is the value of the following expression?

True or False or True or False

True
Explanation:

At least one operand is True.

Question 8

What is the value of the following expression?

True and True and True and False

False
Explanation:

One of the operands is False, making the whole expression False.

Question 9

What is the value of the following expression?

not False and False

False
Explanation:

The not operator has highest precedence, followed by and, and finally or. So this should be interpreted as (not False) and False.

Question 10

What is the value of the following expression?

True and True or True and False

True
Explanation:

The operator not has highest precedence, followed by and, and finally or. So this should be interpreted as (True and True) or (True and False).