- Himanshu Ramchandani
- Posts
- Relational Operators are not must, But a Bonus
Relational Operators are not must, But a Bonus
Relational Operators show the relation between two values, whether it is True or False
#WrittenByHuman
Relational Operators - Himanshu Ramchandani
Following are the relational operators.
> < >= <= == !=
Greater than
print(10 > 5)
True
print(5 > 7)
False
Less than
print(11 < 3)
False
print(4 < 15)
True
Fun Question: How do you know which is greater than and which is less than in >
<
. Haha, got you!!
Greater than and Equal to
print(10 >= 10)
True
What’s the difference between =
and ==
in Python?
=
is used to assign a value to a variable, like this
a = 10
print(a)
Here the value of a is 10
==
is a relation operator, it is used to compare the values on both sides, like this:
print(10 == 10)
True
10 is equal to 10, it means. It compares both values.
Not equal to
!=
print(11 != 10)
True
11 is not equal to 10, it’s a correct statement.
Reply