Labs ICT
🎓 SIWES/IT Login

Booleans

1 min read | Python Tutorial
🎓

Doing SIWES / IT attachment?

Get a structured training programme, a supervised digital logbook, and a completion certificate with LabsICT SIWES / IT.

Explore SIWES / IT Training

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))

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)

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)