Comparison operators

Comparison operators

Comparison operators are used to comparing values. It either returns True or False according to the condition.

 Operator Meaning Example > Greater than – True if the left operand is greater than the right x > y < Less than – True if left operand is less than the right x < y <= Less than or equal to – True if the left operand is less than or equal to the right x <= y >= Greater than or equal to – True if the left operand is greater than or equal to the right x>=y == Equal to – True if both operands are equal x==y != Not equal to – True if operands are not equal x!=y

Example:1

```a=10
b=20
print(a>b)
#or
t=a>b
print(t)```

Output:

False
False

Example:2

```a=10
b=20
print(a<b)
#or
t=a<b
print(t)```

Output:

True
True

Example:3

```a=10
b=20
print(a==b)
#or
t=a==b
print(t)```

Output:

False
False

Example:4

```a=10
b=20
print(a!=b)
#or
t=a!=b
print(t)```

Output:

True
True

Example:5

```a=10
b=20
print(a<=b)
#or
t=a<=b
print(t)```

Output:

True
True

Example:6

```a=10
b=20
print(a>=b)
#or
t=a>=b
print(t)```

Output:

False
False

Important Pages