Python Operators क्या हैं?
Arithmetic, Comparison और Logical Operators को आसान भाषा और practical examples के साथ सीखें।
इस lesson में हम जानेंगे कि Python में Operators क्या होते हैं और उनका उपयोग Mathematical Calculation, Comparison और Logical Conditions में कैसे किया जाता है।
हम निम्न Operators को examples के साथ समझेंगे:
Arithmetic → Comparison → Logical → Assignment
🐍 Operator क्या होता है?
Programming में जब हमें दो या दो से अधिक values पर कोई operation करना होता है, तब हम Operators का उपयोग करते हैं।
उदाहरण के लिए अगर हमें 10 और 5 को जोड़ना है, तो हम + Operator का उपयोग करेंगे।
10 + 5
यहाँ + एक Operator है।
Operator एक ऐसा symbol या keyword है जो किसी value या values पर कोई operation करता है।
1️⃣ Arithmetic Operators
Arithmetic Operators का उपयोग Mathematical Calculations के लिए किया जाता है।
| Operator | नाम | Example |
|---|---|---|
+ |
Addition | 10 + 5 = 15 |
- |
Subtraction | 10 - 5 = 5 |
* |
Multiplication | 10 * 5 = 50 |
/ |
Division | 10 / 5 = 2.0 |
% |
Modulus | 10 % 3 = 1 |
** |
Exponent | 2 ** 3 = 8 |
// |
Floor Division | 10 // 3 = 3 |
➕ Addition Operator
+ Operator का उपयोग दो numbers को जोड़ने के लिए किया जाता है।
a = 10
b = 20
result = a + b
print(result)
Output:
30
➖ Subtraction Operator
a = 20
b = 8
print(a - b)
Output:
12
✖️ Multiplication Operator
a = 10
b = 5
print(a * b)
Output:
50
➗ Division Operator
Python में / Operator Division के लिए उपयोग होता है।
print(10 / 2)
Output:
5.0
/ से Division करने पर
result सामान्यतः Float में मिलता है।
🔢 Modulus Operator (%)
Modulus Operator Division के बाद बचा हुआ remainder देता है।
print(10 % 3)
Output:
1
क्योंकि 10 को 3 से divide करने पर remainder 1 बचता है।
⚡ Exponent Operator (**)
** Operator का उपयोग Power निकालने के लिए किया जाता है।
print(2 ** 3)
Output:
8
इसका अर्थ है:
2 × 2 × 2 = 8
🔽 Floor Division (//)
// Operator Division का floor result देता है।
print(10 // 3)
Output:
3
2️⃣ Comparison Operators
Comparison Operators का उपयोग दो values की तुलना करने के लिए किया जाता है। इसका result सामान्यतः True या False होता है।
| Operator | अर्थ |
|---|---|
== |
बराबर है |
!= |
बराबर नहीं है |
> |
से बड़ा |
< |
से छोटा |
>= |
बड़ा या बराबर |
<= |
छोटा या बराबर |
Example:
a = 10
b = 20
print(a == b)
print(a < b)
print(a > b)
Output:
False
True
False
3️⃣ Logical Operators
Logical Operators का उपयोग एक से अधिक conditions को combine करने के लिए किया जाता है।
| Operator | अर्थ |
|---|---|
and |
दोनों conditions True होनी चाहिए |
or |
कम से कम एक condition True हो |
not |
Result को उलट देता है |
and Example:
age = 20
print(age > 18 and age < 30)
Output:
True
or Example:
age = 15
print(age < 18 or age == 20)
Output:
True
not Example:
is_student = True
print(not is_student)
Output:
False
4️⃣ Assignment Operators
Assignment Operators का उपयोग Variable को value assign करने या उसकी value update करने के लिए किया जाता है।
x = 10
x += 5
print(x)
Output:
15
यहाँ x += 5 का अर्थ है:
x = x + 5
🚀 Practical Python Program
अब एक छोटा program बनाते हैं जिसमें User से दो numbers लेकर कई operations किए जाएंगे।
num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))
print("Addition =", num1 + num2)
print("Subtraction =", num1 - num2)
print("Multiplication =", num1 * num2)
print("Division =", num1 / num2)
print("Remainder =", num1 % num2)
Example Output:
Enter first number: 20
Enter second number: 6
Addition = 26
Subtraction = 14
Multiplication = 120
Division = 3.3333333333333335
Remainder = 2
🧠 Practice Questions
Question 1:
Python में Addition के लिए कौन-सा Operator उपयोग होता है?
Answer: +
Question 2:
10 % 3 का result क्या होगा?
Answer: 1
Question 3:
Python में दो values की तुलना करने के लिए कौन-से Operators उपयोग किए जाते हैं?
Answer: Comparison Operators
Question 4:
and Operator का उपयोग किसलिए होता है?
Answer: Multiple conditions को combine करने के लिए।
❓ Frequently Asked Questions
Python Operator क्या है?
Python में Operator एक symbol या keyword है जिसका उपयोग values पर operation करने के लिए किया जाता है।
Python में Arithmetic Operators कौन-कौन से हैं?
Python के प्रमुख Arithmetic Operators हैं: +, -, *, /, %, ** और //।
Comparison Operator का result क्या होता है?
Comparison Operators का result सामान्यतः True या False होता है।
Python में Logical Operators कौन-कौन से हैं?
Python में प्रमुख Logical Operators हैं: and, or और not।
Python में % Operator का क्या उपयोग है?
% यानी Modulus Operator Division के बाद बचा हुआ remainder देता है।
📖 आज हमने क्या सीखा?
- Operator क्या होता है?
- Arithmetic Operators
- Comparison Operators
- Logical Operators
- Assignment Operators
- Modulus और Floor Division
- Python में Operators का practical use
🐍 RBSE Python — Python Programming सीखें Step by Step