Relational Operators
Relational operators are used to compare the values and determines the relation between the operands.
The Relational operators that we can perform in python are:
- Equal To(==)
- Not Equal To(!=)
- Greater Than(>)
- Less Than(<)
- Greater Than or Equal To(>=)
- Less Than or Equal To(<=)
Equal To(==)
Equal to operator checks if two values or equal or not. If both values are equal then it returns True else False.
a=100 b=120 print(a == b)Output
False
Not Equal To(!=)
Not Equal To checks if two values are equal or not. If two values are not equal then it returns True else returns False.
a=45 b=64 print(a != b)Output
True
Greater Than(>)
Greater Than checks if the right operand is greater than the left operand . If the right operand is greater than left then it returns True else returns False.
a=65 b=74 print(a > b)Output
False
less Than(<)
Less Than checks if the right operand is lesser than the left operand then it returns True and returns False.
a=85 b=985 print(a < b)Output
True
Greater Than or Equal To(>=)
Greater Than or Equal To operator checks if the right operand is greater or equal to the left operand. If the right operand is greater than or equal to left operand it returns True else returns False.
a=75 b=75 print(a >= b)Output
True
Less Than or Equal To(<=)
Less Than or Equal To returns True if the right operand is less than or equal to the left operand else it returns False.
a=85 b=64 print(a <= b)Output
False
0 comments :
Post a Comment
Note: only a member of this blog may post a comment.