Q:

what is a Boolean python

#In programming you often need to know if an expression is True or False.
#You can evaluate any expression in Python, and get one of two answers,
#True or False. When you compare two values, the expression is evaluated
#and Python returns the Boolean answer: 
#Example:
  
print(10 > 9) #This returns true because this calculation is true
print(10 == 9) #This returns false because this calculation is false
print(10 < 9) #This returns false because this calculation is false



#Print a message based on whether the condition is True or False:
#Example:

a = 200
b = 33

if b > a:
  print("b is greater than a")
else:
  print("b is not greater than a")
1
>>> # The not operator is the opposite of it
>>> not True
False
>>> not False
True
>>> # The and operator is True only if both are are true
>>> True and True
True
>>> False and True
False
>>> False and False
False
>>> # The or operator is True if either of them are true
>>> True or True
True
>>> False or True
True
>>> False or False
False
1
# Booleans represent one of two values: True or False.
# When you compare two values, the expression is evaluated and Python returns the Boolean answer:
print(10 > 9)
> True
print(10 < 9)
> False
# All True Examples
bool("abc")
bool(123)
bool(["apple", "cherry", "banana"])
# All False Examples
bool(False)
bool(None)
bool(0)
bool("")
bool(())
bool([])
bool({})
5
#Booleans are True or False values

t = True
f = False
1
checker = None 

if some_decision:
    checker = True

if checker:
    # some stuff
-1

New to Communities?

Join the community