Loading...
Python

Relational Operators

These operators are used to check the relation between two input values such as <,=,>,<=,>=. The result will be given in boolean type or bool.

Example 1:

a=10
b=20
print(“a<b is “,a<b)
print(“a=b is “,a=b)
print(“a>b is “,a>b)
print(“a<=b is “,a<=b)
print(“a>=b is “,a>=b)

Output:

a<b is True
a=b is False
a>b is False
a<=b is True
a>=b is False

Relation Operators are also applied for string or str type

Example 2:

x=”Webnoid”
y=”Webnoid”
print(“a>b is “,a>b)
print(“a=b is “,a=b)
print(“a<b is “,a<b)
print(“a>=b is “,a>=b)
print(“a<=b is “,a<=b)

Output:

a>b is False
a=b is True
a<b is False
a>=b is True
a<=b is True

Equality Operators:

These operators are used to check the equality. We can apply these operators For any type even for incompatible type.
These operators are ==,!=

Example:

10==20
False
>>>10!=20
True
>>>10==True
False
>>>False==False
True
>>>”webnoid”==”webnoid”
True
>>>”webnoid”!=10
False

Leave a Reply

Your email address will not be published. Required fields are marked *