For more information about Booleans in Python visit our website at http://learnpythontutorial.com/learn-...
Python Booleans
In this Python tutorial, we will take a look at Python booleans. A boolean is a truth statement which is either True or False. You may be asking why we are looking at booleans in the numbers section of our Python tutorials. Well believe it or not booleans are actually integers. True is equal to one and False is equal to zero in Python. Truth statements are very useful when we use flow control statements which we will cover in full in a later tutorial.
Examples of Python Booleans
In the examples below focus on True and False. I throw some new operators like boolean operators and comparison operators which we will cover both in next two tutorials.
Example of Python Booleans
#Boolean Operators
True and True
True
True or True
True
not False
True
False
7 == 7
True
7 != 8
True
#Proof That a Boolean is actually an integer
True + False
1
type(True)
class 'bool'
a = True + False
type(a)
class 'int'
If you have any questions about booleans leave a comment below and we will do our best to help you understand.
Auf dieser Seite können Sie das Online-Video Python Tutorial: Booleans in Python - Python Numbers #37 mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Code master 26 März 2015 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 3,929 Mal angesehen und es wurde von 27 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!