OR Operator

The full text of this chapter, to read or revisit. To practise, do the exercises.

β–Ά Do the exercises

Exercise 1 β€” OR Operator

The or operator is a logical operator that returns True if at least one side is True. Otherwise, it returns False.

Here is a truth table for the or operator with 2 variables (A or B = ?). It shows all possible combinations of True and False.

Exercise 2 β€” OR Operator

We can also try to display the truth table with code !

print("False or False =", False or False) print("True or False =", True or False) print("False or True =", False or True) print("True or True =", True or True)

Remember, or returns True if at least one side is True.

Exercise 3 β€” Did you get OR?

Match each formula of the left with its result on the right.

Items to match
β€’ True or True
β€’ True or False
β€’ False or True
β€’ False or False
Definitions
β€’ True
β€’ True
β€’ True
β€’ False

Exercise 4 β€” OR Operator Quiz

What will be the result of False or True?

Options
β€’ True
β€’ False
β€’ Error
β€’ None

Hint : With OR operator, if at least one side is True, the result is True. Since one side is True, the result is True.

Exercise 5 β€” Match OR Results

Match each OR operation with its correct result. In these type of operations, you're gonna want to read from left to right, evaluating what's within parentheses first if there are any, AND is evaluated before OR (similar to multiplication before addition).

Items to match
β€’ True or True or True
β€’ False or True or False
β€’ False or False or False
β€’ True or False or True
Definitions
β€’ True
β€’ True
β€’ False
β€’ True

Exercise 6 β€” Match Complex Boolean Results

Match each boolean operation with its correct result. Remember: evaluate what's in parentheses first, then AND operations, and finally OR operations (reading left to right).

Items to match
β€’ (True or False) and True
β€’ False or (True and False)
β€’ (False and True) or True
β€’ True and (False or True)
β€’ (True and False) or False
Definitions
β€’ True
β€’ False
β€’ True
β€’ True
β€’ False
Back to the course