-
Book Overview & Buying
-
Table Of Contents
Python Illustrated
By :
Booleans are like simple answers to closed questions: either yes or no. They’re super helpful when we need our code to make decisions, such as whether it’s time for a nap (spoiler: it’s always time for a nap). So, whenever there should be more than two options, booleans are not the data type you’re looking for.
Booleans represent the concept of truthiness in programming. In Python, they are True or False (make sure to capitalize the first letter).
Here are some facts about Wiesje right now:
is_hungry = True
is_sleepy = False
This is how to assign booleans directly. We will do cool things with them in the next chapter. For now, I want to talk about other ways we can get a boolean value.
Booleans are often the result of comparisons or evaluations, and we do these with the use of comparison operators. Just like + and - are operators, these are operators too. The + and - operators result in a...