Python Tutorial: Booleans in Python - Python Numbers #37

Publicado el: 26 marzo 2015
en el canal de: Code master
3,929
27

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.


En esta página del sitio puede ver el video en línea Python Tutorial: Booleans in Python - Python Numbers #37 de Duración hora minuto segunda en buena calidad , que subió el usuario Code master 26 marzo 2015, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 3,929 veces y le gustó 27 a los espectadores. Disfruta viendo!