Important Notice:

Relational (Comparison) Operators

Relational (Comparison) Operators

30 views 4 min read

Relational (Comparison) Operators (तुलनात्मक ऑपरेटर) :-

Relational Operators (तुलनात्मक ऑपरेटर) वे Operators हैं जिनका उपयोग दो या दो से अधिक values या expressions की तुलना (Comparison) करने के लिए किया जाता है। इनका result हमेशा Boolean value (True या False) होता है।
Python में Relational Operators का उपयोग दो values के बीच संबंध जानने के लिए किया जाता है, जैसे कि कोई value दूसरी value से बड़ी > (Greater), छोटी < (Less), बराबर ==(Equal) या बराबर नहीं != (Not Equal) है।
 
English
Relational (Comparison) Operators are used to compare two or more values or expressions. They always return a Boolean value (True or False) as a result.
These operators are commonly used in conditional statements, loops, and decision-making programs.
 
Syntax -
               operand1 operator operand2
 
Example -
a = 20
b = 10
print(a > b)
Output -
True
Relational Operators की List :-
 
==  Equal to    बराबर
!=  Not Equal to    बराबर नहीं
>   Greater than    से बड़ा
<   Less than   से छोटा
>=  Greater than or Equal to    से बड़ा या बराबर
<=  Less than or Equal to   से छोटा या बराबर
 
1. Equal to Operator (==) :-
The Equal to Operator (==) is used to check whether two values are equal or not.
Equal to Operator (==) का उपयोग यह जाँचने के लिए किया जाता है कि दो values बराबर हैं या नहीं।
यदि दोनों values बराबर होती हैं, तो result True होता है, अन्यथा False होता है।
 
Syntax -
result = operand1 == operand2
 
Example -
a = 25
b = 25

 

print(a == b)
 
Output -
True
2. Not Equal to Operator (!=) :-
The Not Equal to Operator (!=) is used to check whether two values are different or not.
Not Equal to Operator (!=) का उपयोग यह जाँचने के लिए किया जाता है कि दो values अलग हैं या नहीं।
यदि दोनों values अलग होती हैं, तो result True होता है।
 
Syntax -
result = operand1 != operand2
Example -
a = 25
b = 15

 

print(a != b)
Output -
True
 
3. Greater than Operator (>)  :-
The Greater than Operator (>) is used to check whether the first value is greater than the second value.
Greater than Operator (>) का उपयोग यह जाँचने के लिए किया जाता है कि पहली value दूसरी value से बड़ी है या नहीं।

 

Syntax -
result = operand1 > operand2
 
Example -
a = 25
b = 15

 

print(a > b)
 
Output -
True
 
4. Less than Operator (<)  :-
The Less than Operator (<) is used to check whether the first value is less than the second value.
Less than Operator (<) का उपयोग यह जाँचने के लिए किया जाता है कि पहली value दूसरी value से छोटी है या नहीं।
 
Syntax -
result = operand1 < operand2
Example -
a = 10
b = 20

 

print(a < b)
Output -
True
 
5. Greater than or Equal to Operator (>=)  :-
The Greater than or Equal to Operator (>=) checks whether the first value is greater than or equal to the second value.
Greater than or Equal to Operator (>=) का उपयोग यह जाँचने के लिए किया जाता है कि पहली value दूसरी value से बड़ी या बराबर है।
 
Syntax -
result = operand1 >= operand2
Example -
a = 25
b = 25

 

print(a >= b)
Output -
True
यहाँ 25 >= 25 है, इसलिए result True है।
 

 

6. Less than or Equal to Operator (<=) :-
The Less than or Equal to Operator (<=) checks whether the first value is less than or equal to the second value.
Less than or Equal to Operator (<=) का उपयोग यह जाँचने के लिए किया जाता है कि पहली value दूसरी value से छोटी या बराबर है।
 
Syntax -
result = operand1 <= operand2
 
Example -
a = 15
b = 25

 

print(a <= b)
 
Output -
True
 
 
Relational Operators Using User Input in One Program :-
 
a = int(input("Enter First Number: "))
b = int(input("Enter Second Number: "))
print("\nFirst Number :", a)
print("Second Number:", b)
print("\nEqual to (==)                  :", a == b)
print("Not Equal to (!=)              :", a != b)
print("Greater than (>)               :", a > b)
print("Less than (<)                  :", a < b)
print("Greater than or Equal to (>=)  :", a >= b)
print("Less than or Equal to (<=)     :", a <= b)
 
Output -
 
Enter First Number: 20
Enter Second Number: 10
First Number : 20
Second Number: 10
Equal to (==)                  : False
Not Equal to (!=)              : True
Greater than (>)               : True
Less than (<)                  : False
Greater than or Equal to (>=)  : True
Less than or Equal to (<=)     : False

Related Notes