Labs ICT
Pro Login

Booleans

Boolean Values

Booleans represent one of two values: True or False. They're the foundation of logic in programming.

is_sunny = True
is_raining = False
print(is_sunny)
print(is_raining)
print(type(is_sunny))
Try it Yourself →

Comparisons Produce Booleans

Any comparison expression evaluates to a boolean. This is how conditions work in Python.

print(10 > 5)
print(10 == 5)
print(10 != 5)
print("hello" == "world")
print(3 <= 3)
Try it Yourself →

Logical Operations with Booleans

Combine booleans with and, or, and not to create complex conditions.

has_license = True
has_insurance = False

print(has_license and has_insurance)
print(has_license or has_insurance)
print(not has_license)
Try it Yourself →