Introduction to Boolean ValuesΒΆ
When writing a program to automate a task, it is often necessary for the program to be able to check whether or not a certain logical condition is true, and then select an action based on this evaluation. As a tool for working with evaluation logical expressions, Python provides us with a Boolean data type. Boolean variables can take only one of only two values: True
or False
.
In the next two cells, we will create two boolean variables. For each variable, we will print its value, as well as its type.
varT = True
print(varT)
print(type(varT))
True
<class 'bool'>
varF = False
print(varF)
print(type(varF))
False
<class 'bool'>