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 statements control the flow of execution. As with function definitions, the bodies of if statements are indented, as are the bodies of elif and else clauses.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.14.131.47