Book Image

Python Essentials

By : Steven F. Lott
Book Image

Python Essentials

By: Steven F. Lott

Overview of this book

Table of Contents (22 chapters)
Python Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Summary


We've looked closely at Python's Boolean data type, which only has two values (True and False) and four operators: and, or, not, and if-else. The Boolean operators and the if statement will both implicitly coerce values to a Boolean. This means that non-empty strings will behave in the same as the True value.

We've looked at the comparison operators. These work with other objects and create Boolean results.

In the case of numeric comparisons, the numeric coercion rules are used to allow us to compare float against int values without having to write explicit conversions. For string or tuple values, we've seen that items are compared in order.

We've also seen how the logical operators of or and and are not strict about evaluating their operands. If the left-hand side of and is False, the right-hand side isn't evaluated. Similarly, if the left-hand side of or is True, the right-hand side isn't evaluated.

We looked at several kinds of Python statements, including the if-elif-else statement...