Python 2.2.1 and later have built-in Boolean data types True and False, which are associated with the bool() built-in function. (Other functions and methods also return Boolean results, such as isdigit().) Comparison expressions, such as x < y, also return
History geeks may be interested to know that previous versions of Python used 1 and 0 rather than True and False because that's how it works in the C programming language. The odd result of this is that the True and False data types are integers:
It's important to remember that the Boolean data types are not the same thing as the truth values of objects returned by Boolean operators. When you check the truth value of objects by using Boolean operators (for example, by using x and y), you are checking whether the objects are empty. The Boolean operators return a Python object (for example, in x and y, the object x or the object y is returned); they don't necessarily return True or False.
Was this article helpful?