Boolean operators - Answers
Q1. For all questions:
s = 5
t = 10
u = 20
| Boolean expression | True or False? |
| s < u and u > t | True |
| t > s and s == 5 | True |
| s != u and t != s | True |
| 5 = s or t != 20 | Error - using the assignment symbol |
| not s == 5 | False |
| not u > 10 | False |
| s > 10 or u <= 20 | True |
| u != 10 or t == 10 | True |
| t >= 5 and s == 10 or u < 10 | False |
| s >= 5 and not t == 10 | False |
| not u <= 20 and t < 50 | False |
| s == 5 and t == 5 and u == 20 | False |
| not s != 5 and not t != 5 | False |
| (s != 5 or t == 10) and u != 30 | True |
| (t == 10) or (u == 20) | True |
| (not s != 10) or (not t != 10) | True |
| u == 20 and not t < 30 | False |
| s > 1 or (u = 20 and t <= 10) | Error - using the assignment symbol |
| (not s != 10) or (not t == 10) | False |
| (not t != 10) and (not s != 5) | True |
Q2. Students should be encouraged to predict answers before using Python. They should then check their answers with a friend's and try to work out why any differences occurred. Only then should they use Python to check their answers.