In all programming languages you will find logical operators. Logical operators are used to combine conditional statements. There are three logical operators in Python.
Now, let’s see the logical operators in Python:
||Returns True if both statements are true
||x < 5 and x < 10
||Returns True if one of the statements is true
||x < 5 or x < 4
||Returns False if the result is true
||not(x < 5 and x < 10)
Python Code with logical operators:
if x<=5 and y<=5:
print("inputs are ok")
print("inputs are not ok")
inputs are not ok
In this tutorial, I have shown logical operators in Python. Hope you have enjoyed the tutorial. If you want to get updated, like my facebook page http://www.facebook.com/freetechtrainer and stay connected.