Boolean Data Type
Also known as logical operators and are commonly used in conditional statements (if...) or constructing loops (while... for...).
For example, you could join to two comparisons in an ‘if’ statement using ‘and’, like this:
if a >= 0 and a <= 10:
print (“Your number is between 0 and 10”)
else
print (“Out of range - must be between 0 & 10”)
Using the ‘and’ operator would mean both conditions (a >= 0) and (a <= 10) must be true.
Get Python Made Easy now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.