Boolean#
Booleans are extensively used in control structures like if statements, while loops, and logical operations.
A boolean represents one of two possible values: True or False, and boolean operators (and, or, and not) can be used to combine or negate boolean values in your code.
Let’s define two boolean conditions and print the result:
# Boolean expressions
are_you_abe_student = True
are_you_python_expert = False
your_learning = are_you_abe_student and not are_you_python_expert
print(f"Am I learner? {your_learning}")
Am I learner? True
Make a comparison between two numbers and print the boolean result:
# Logical operations
result = (5 > 3) # Evaluates to True
print(result)
True