Boolean datatype usually known as binary system, that means 0 or 1 .
0= False
1= True
Creating Boolean Values:
Booleans are created by assigning True or False to a variable, or as a result of logical operations.
Example of Boolean datatype:
a = True
b = False
print(type(a)) # Output: <class 'bool'>
print(type(b)) # Output: <class 'bool'>
Python supports several operations that return boolean values, including comparison operators and logical operators.
Boolean Conversion:
You can convert other data types to boolean using the bool() function. In Python, the following values are considered False in a boolean context:
All other values are considered True.
Examples:
print(bool(1)) # Output: True
print(bool(0)) # Output: False
print(bool(-1)) # Output: True
print(bool(3.14)) # Output: True
print(bool('')) # Output: False
print(bool('Hello')) # Output: True
print(bool([])) # Output: False
print(bool([1, 2, 3])) # Output: True
print(bool(None)) # Output: False