Booleans
# Type these in your Python interpeter and you'll get them back
True
False
# We can get their inverses with the not operator
not True
not False
# We can use the 'or' operator, which returns True if any one of the values
# are True
True or False # True
True or True # True
False or True # True
False or False # False
# We can also use the 'and' operator, which returns True only if both values
# are True
True and False # False
True and True # True
False and True # False
False and False # False
# We can chain them with the 'not' operator as well
not (True and False) # True
not (True and True) # False
not (False and True) # True
not (False and False) # TrueExercises
Last updated