Booleans
Python can work out if an expresion is true or false e.g. is 10 greater than 5? When we work out those conditional expresses, Python gets a Boolean value: either the expression is True
or the expression is False
. You have to write to True and False exactly like that! TRUE or true or tRue won't cut it. Let's see them in action:
We know variables can store numbers and string, they can also store Booleans as well. A variable can store any data type. And like numbers and strings, you can use operators on them. In this case you can use: or, and, not.
Exercises
Work out the following boolean expressions
not False
True and (not False)
not (not True)
not (False or True)
False and not (True or (False or not False))
True and True and True
True and not (True or not (False and True))
Last updated