Python boolean type is one of the built-in data types provided by Python, which represents one of the two values i.e. True or False. Generally, it is used to represent the truth values of the expressions. For example, 1==1 is True whereas 2<1 is False.
In programming you often need to know if an expression is True or False.
You can evaluate any expression in Python, and get one of two answers, True or False.
When you compare two values, the expression is evaluated and Python returns the Boolean answer.
a = 0
b = 1
print (a==b) ## returns False
print (a!=b) ## returns True
The
a = bool ("hello" )
print (a)
print (bool (0 ))
print (bool (10 ))
print (bool (-0 ))
A number
x = bool ("" )
print (x) ## False
print (bool (0 )) ## False
print (bool ([] )) ## False
print (bool (() )) ## False
print (bool ({} )) ## False
print (bool (1.444 )) ## True