Logical Operators
Share: Facebook |
Twitter |
Whatsapp |
Linkedin Visits: 474
Logical Operators
#ScriptsKart
# Python has three logical operators:
# 1. and
# 2. or
# 3. not
# 1. and operator checks whether two conditions are both True simultaneously:
price = 9
print(price > 9 and price < 15) # false
# 2. or operator checks multiple conditions. But it returns True when either
# or both individual conditions are True:
print(price > 9 or price < 15) # true
# 3. not operator applies to one condition. And it reverses the result of that
# condition, True becomes False and False becomes True
print( not price > 8) # False
# The precedence of the logical operator from the highest to lowest:
# not, and, and or
#ScriptsKart