Articles → Python → Comparison Operator In Python
Comparison Operator In Python
Comparison Operators
- Equals operator (==) → If the value of the left-hand side is equal to the value of the right-hand side, then returns true else false
- Not equals (! =) → If the value of the left-hand side is not equal to the value of the right-hand side, then returns true else false
- Greater than (>) → If the value of the left-hand side is greater than the value of the right-hand side then returns true else false
- Less than (<) → If the value of the left-hand side is less than the value of the right-hand side then returns true else false
- Greater than and equals to (>=) → If the value of the left-hand side is greater than or equal to the value of the right-hand side then returns true else false
- Less than and equals to (<=) → If the value of the left-hand side is less than or equal to the value of the right-hand side then returns true else false
Example
a = 5
b = 6
#conditonal operators
print(a==b) # returns false
print(a!=b) # returns true
print(a>b) # returns false
print(a<b) # returns true
print(a>=b) # returns false
print(a<=b)# returns true
Output