Python Comparison Operators
Python Comparison Operators
Comparison operators are used to compare
two values. these are easy and simple to understand as they return the boolean value. i.e. True or false. Comparison
operators are also known as the relational operators.
|
Operators |
Description |
Syntax |
|
== |
Equal to : True
if both operands are equal. |
a == b |
|
!= |
Not equal : True if both operands are unequal. |
a != b |
|
> |
Greater than : True if 1st operand is
greater than 2nd operand. |
a > b |
|
< |
Less than : True if 1st operand is less than 2nd
operand. |
a < b |
|
>= |
Greater than or equal to : True if 1st
operand is greater than or equal to 2nd
operand. |
a >= b |
|
<= |
Less than or equal to : True if 1st operand is less than or
equal to 2nd operand. |
a <= b |
Example
:
a = 5
b = 10
print (a == b)
print (a > b)
print (a < b)
print (a != b)
print (a >= b)
print (a <= b)
Output
:
False
False
True
True
False
True
Conclusion : In this we
see about the comparison operator in python.

Good Information 👍
ReplyDelete