Python Program To Demonstrate Comparison Operator

Write Python code to demonstrate comparison operators

# WAP for comparison operator

a = 10
b = -3
c = 8
print("\nThe value of a :", a)
print("\nThe value of b :", b)
print("\nThe value of c :", c)

print("\na Is Equal to b :", a == b)
print("\na Is Equal to c :", a == c)
print("\na Is Greater than b :", a > b)
print("\na Is Greater than c :", a > c)
print("\na Is Less than b :", a < b)
print("\na Is Less than c :", a < c)
print("\na dose not equal to b :", a != b)
print("\na dose not equal to c :", a != c)
print("\na Is Greater than or equal to b :", a > b)
print("\na Is Greater than or equal to c :", a >= c)
print("\na Is Less than or equal to b :", a < b)
print("\na Is Less than or equal to c :", a <= c)

Output:

The value of a : 10
The value of b : -3
The value of c : 8
a Is Equal to b : False
a Is Equal to c : False
a Is Greater than b : True
a Is Greater than c : True
a Is Less than b : False
a Is Less than c : False
a dose not equal to b : True
a dose not equal to c : True
a Is Greater than or equal to b : True
a Is Greater than or equal to c : True
a Is Less than or equal to b : False
a Is Less than or equal to c : False

<< Previous | Next >>


Leave a Reply

Your email address will not be published.