# Lab 4: Knowledge Check

These questions check your knowledge of concepts from this lab. Use the button at the bottom to show your answers once you've attempted them.

1. The operands of comparison operators like '<' should always be Boolean values.
True False
2. The operands of logical operators like 'and' should normally be Boolean values.
True False
3. Which of the following functions is a predicate? (pick one or more)
1. ``````def a():
return True``````
2. ``````def b(x):
if x < 3:
return True
else:
return False``````
3. ``````def c(x):
if x < 3:
return True``````
4. ``````def d(x):
return x < 3``````
5. ``````def e(x):
return x + 3``````
4. Given the following predicate:
``````def canRide(age):
return age >= 8``````
...which of the following pieces of code correctly prints `'You can ride.'` when `age` is at least 8, and not otherwise? (pick one or more)
1. ``````if canRide:
print('You can ride.')``````
2. ``````if canRide():
print('You can ride.')``````
3. ``````if canRide(age):
print('You can ride.')``````
4. ``````if age >= canRide:
print('You can ride.')``````
5. ``````if age >= canRide(age):
print('You can ride.')``````
6. ``````if not canRide(age):
pass
else:
print('You can ride.')``````
5. Using the same `canRide` predicate, which of the following expressions evaluates to `True`? (pick one or more)
1. ``not canRide(5)``
2. ``canRide(8)``
3. ``canRide(22)``
4. ``canRide(8) and canRide(22)``
5. ``canRide(5) or canRide(10)``
6. ``canRide(9) == True``
7. ``((canRide(9) == True) == True) == True``
6. What is the result of the following expression?
``3 > 5 or (2 < 3 and 'hello' > 'goodbye')``

True False