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.
In questa pagina del sito puoi guardare il video online Python Tutorial: Booleans in Python - Python Numbers #37 della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Code master 26 marzo 2015, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 3,929 volte e gli è piaciuto 27 spettatori. Buona visione!