Booleans are quite useful because they can represent represent the result of a comparison between values. For instance, the following comparison operators return a boolean which determines if the comparison is true or false.
print(1 == 1) print(2 > 3)
which prints
True
False
Here is a list of comparison operators in Python:
<: less than<=: less than or equal>: more than>=: more than or equal==: equal!=: not equalis: same object identityis not: different object identityNote: The difference between is and == is that is requires the objects to be the same, not just the values. We will see examples of this later in this module.
Create the following variables:
n_points and set it to 5n_min_points and set it to 0n_max_points and set it to 100Finally, create a variable called is_in_range and set it to the result of applying the comparison operators to check if n_points is between n_min_points and n_max_points (i.e. greater or equal than the minimum and smaller or equal than the maximum).
Note: You will need to use the and boolean operator (see previous items).