You Learned About Booleans: True or False?
In this chapter, you learned the following:
-
Python uses Boolean values, True and False, to represent what is true and what isn’t. Programs can combine these values using three operators: not, and, and or.
-
Boolean operators can also be applied to numeric values. 0, 0.0, the empty string, and None are treated as False; all other numeric values and strings are treated as True. It is best to avoid applying Boolean operators to non-Boolean values.
-
Relational operators such as “equals” and “less than” compare values and produce a Boolean result.
-
When different operators are combined in an expression, the order of precedence from highest to lowest is arithmetic, relational, and then Boolean.
-
if
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access