Python Hindi Logo
Python in Hindi | Programming Education
Python programming tutorial in Hindi banner Python code learning illustration Hindi Python student coding illustration Python data code pattern background
🇮🇳 Learn Python in Hindi

Python Tutorial in HindiiLearn Python Programming for Free

Learn Python from Beginner to Advanced in simple Hindi. Explore tutorials, projects, interview questions, quizzes, notes, and career guidance—all in one place.

50+
Tutorials
100%
Free
Hindi
Medium
print("Namaste Python!")
# Variable banana
naam = "Ankit"
umar = 25
 
for i in range(3):
  print("Sikho!")
 
# Output:
Sikho! Sikho! Sikho!

Python Operators in Hindi — Complete Guide with Examples for Beginners | (Arithmetic, Comparison, Logical, Bitwise)

Python Operators in Hindi - Arithmetic, Comparison, Logical aur Bitwise Operators ka illustration

Python Operators in Hindi (Complete Guide)

Python आज दुनिया की सबसे लोकप्रिय programming languages में से एक है। इसका उपयोग Web Development, Data Science, Artificial Intelligence, Machine Learning, Automation, Cyber Security और Software Development जैसे कई क्षेत्रों में किया जाता है। लेकिन किसी भी Python Program को सही तरीके से लिखने के लिए सबसे पहले Operators को समझना बहुत जरूरी होता है।

जब भी हम किसी Program में दो numbers को जोड़ते हैं, किसी value की तुलना करते हैं, conditions check करते हैं या किसी variable में नया value store करते हैं, तब हम Operators का उपयोग करते हैं। इसलिए Operators Python की सबसे महत्वपूर्ण fundamental concepts में से एक हैं।

अगर आपने अभी Python सीखना शुरू किया है, तो यह tutorial आपके लिए एक मजबूत foundation तैयार करेगा। और यदि आप Python Interview की तैयारी कर रहे हैं, तब भी यह topic आपके लिए बेहद महत्वपूर्ण है क्योंकि लगभग हर Python Interview में Operators से जुड़े सवाल पूछे जाते हैं।

इस tutorial में हम Python Operators को आसान भाषा में समझेंगे। प्रत्येक Operator के साथ Practical Examples, Real-world Use Cases और Interview Tips भी दिए जाएंगे ताकि आपको केवल theory ही नहीं बल्कि उसका वास्तविक उपयोग भी समझ आए।

Operator क्या होता है?

Simple भाषा में कहें तो, Operator एक symbol होता है जो किसी operation को perform करने के लिए use होता है। जैसे अगर आपको दो numbers जोड़ने हैं, तो आप + operator use करेंगे।

python
a = 10
b = 5
print(a + b)   # Output: 15

यहाँ + एक operator है, और a, b operands हैं।

Python में मुख्य रूप से 7 प्रकार के operators होते हैं:

  1. Arithmetic Operators
  2. Comparison Operators
  3. Logical Operators
  4. Assignment Operators
  5. Bitwise Operators
  6. Identity Operators
  7. Membership Operators

आज हम Part 1 में पहले दो types — Arithmetic और Comparison Operators — detail में देखेंगे।

1. Arithmetic Operators (गणितीय Operators)

Arithmetic Operators का इस्तेमाल basic math calculations के लिए होता है — जोड़, घटाव, गुणा, भाग वगैरह।

List of Arithmetic Operators

OperatorNameExampleResult
+Addition5 + 38
-Subtraction5 - 32
*Multiplication5 * 315
/Division5 / 22.5
//Floor Division5 // 22
%Modulus5 % 21
**Exponentiation5 ** 225

Code Example

python
a = 10
b = 3

print("Addition:", a + b)         # 13
print("Subtraction:", a - b)      # 7
print("Multiplication:", a * b)   # 30
print("Division:", a / b)         # 3.333...
print("Floor Division:", a // b)  # 3
print("Modulus:", a % b)          # 1
print("Exponent:", a ** b)        # 1000

सबसे ज्यादा confuse करने वाले Operators

/ vs // — बहुत सारे beginners यहाँ confuse होते हैं।

  • / हमेशा float value return करता है (decimal के साथ)
  • // हमेशा floor value return करता है (decimal हटा कर, नीचे की तरफ round करके)
python
print(7 / 2)    # 3.5
print(7 // 2)   # 3
print(-7 // 2)  # -4  (floor की तरफ जाता है, ऊपर नहीं)

यह negative numbers वाला case अक्सर interview में पूछा जाता है, इसे याद रखिए।

Modulus Operator (%) का Real Use

Modulus operator सबसे ज्यादा use होता है यह check करने के लिए कि कोई number even है या odd

python
num = 7
if num % 2 == 0:
    print("Even number")
else:
    print("Odd number")

यह पैटर्न आपको almost हर Python program में दिखेगा — चाहे वो loops हों, या data filtering।

2. Comparison Operators (तुलना करने वाले Operators)

Comparison Operators का काम है दो values को compare करना, और result हमेशा Boolean (True या False) होता है।

List of Comparison Operators

OperatorNameExampleResult
==Equal to5 == 5True
!=Not equal to5 != 3True
>Greater than5 > 3True
<Less than5 < 3False
>=Greater than or equal5 >= 5True
<=Less than or equal5 <= 3False

Code Example

python
x = 10
y = 20

print(x == y)   # False
print(x != y)   # True
print(x > y)    # False
print(x < y)    # True
print(x >= 10)  # True
print(y <= 15)  # False

सबसे बड़ी Beginner Mistake

Python सीखने वाले ज्यादातर students = और == में गलती करते हैं।

python
# गलत तरीका (यह assignment है, comparison नहीं)
if x = 10:
    print("Equal")

ऊपर वाला code error देगा, क्योंकि = assignment operator है, comparison operator नहीं। सही तरीका यह है:

python
# सही तरीका
if x == 10:
    print("Equal")

यह गलती हर beginner करता है, इसलिए ध्यान से practice कीजिए।

Real-World Example: Comparison Operators का Use

मान लीजिए आप एक login system बना रहे हैं, जहाँ user की age check करनी है कि वो 18 साल से ऊपर है या नहीं:

python
age = 20

if age >= 18:
    print("आप वोट डाल सकते हैं")
else:
    print("आप अभी वोट डालने के योग्य नहीं हैं")

यह एक बहुत common real-life use case है जो comparison operators को समझने में मदद करता है।


Part 2

इस Part में हम Cover करेंगे:

  •  Logical Operators
  • Assignment Operators
  •  Bitwise Operators
  •  Real-world Examples
  •  Common Mistakes
  • Interview Tips

Logical Operators in Python

Logical Operators का उपयोग एक से अधिक Conditions को Combine करने के लिए किया जाता है। जब Program में कई Conditions को एक साथ Check करना होता है, तब Logical Operators सबसे महत्वपूर्ण भूमिका निभाते हैं।

Python में मुख्य रूप से तीन Logical Operators होते हैं—

  • and
  • or
  • not

इनका उपयोग सबसे अधिक if, elif, while और Decision Making Programs में किया जाता है।

1. AND Operator (and)

and Operator तभी True Return करता है जब दोनों Conditions True हों।

यदि एक भी Condition False हो जाए, तो Result False होगा।

Example

age = 22
has_license = True

print(age >= 18 and has_license)

Output

True

दूसरा Example

age = 16
has_license = True

print(age >= 18 and has_license)

Output

False

Real-world Example

Driving License Verification

यदि किसी व्यक्ति की उम्र 18 वर्ष या उससे अधिक है और उसके पास Driving License भी है, तभी उसे वाहन चलाने की अनुमति मिलेगी।

2. OR Operator (or)

or Operator तब True Return करता है जब कम से कम एक Condition True हो।

Example

marks = 45
sports_quota = True

print(marks >= 50 or sports_quota)

Output

True

यहाँ Marks कम हैं लेकिन Sports Quota उपलब्ध है, इसलिए Result True आया।

दूसरा Example

print(False or False)

Output

False

Real-world Example

College Admission में Student को Admission मिल सकता है यदि—

  • Entrance Exam Clear हो
  • या Sports Quota हो

3. NOT Operator (not)

not किसी भी Boolean Value को उल्टा (Reverse) कर देता है।

Example

logged_in = True

print(not logged_in)

Output

False

दूसरा Example

print(not False)

Output

True

Real-world Example

Website Login System

यदि User Login नहीं है (not logged_in) तो Login Page Show किया जाता है।

Summary of Logical Operators

OperatorMeaningExample
andदोनों Conditions Truea > 5 and b < 10
orकोई एक Condition Truea > 5 or b < 10
notBoolean उल्टा करता हैnot True    

बहुत सारे beginners And / Or की जगह गलती से &, | इस्तेमाल कर लेते हैं (जो असल में Bitwise Operators हैं, आगे इसी part में पढ़ेंगे)।

python
# गलत (यह bitwise है, boolean logic के लिए recommended नहीं)
if age >= 18 & has_id:
    ...

# सही
if age >= 18 and has_id:
    ...

Boolean conditions के लिए हमेशा and, or, not का ही इस्तेमाल करें।

Assignment Operators (Assignment वाले Operators)

Assignment Operators का इस्तेमाल किसी variable में value assign (store) करने के लिए होता है। साथ ही, यह shortcut तरीके से calculation करके भी value update कर सकते हैं।

List of Assignment Operators

OperatorExampleSame As
=x = 5x = 5
+=x += 3x = x + 3
-=x -= 3x = x - 3
*=x *= 3x = x * 3
/=x /= 3x = x / 3
//=x //= 3x = x // 3
%=x %= 3x = x % 3
**=x **= 3x = x ** 3

Code Example

python
x = 10

x += 5   # x = 15
print(x)

x -= 3   # x = 12
print(x)

x *= 2   # x = 24
print(x)

x //= 5  # x = 4
print(x)

Real-World Use Case: Counter बनाना

Assignment operators सबसे ज्यादा use होते हैं counters और loops में:

python
total_orders = 0

# हर नए order पर counter बढ़ाना
total_orders += 1
total_orders += 1
total_orders += 1

print("Total Orders:", total_orders)  # 3

अगर आप e-commerce या inventory जैसे projects बना रहे हैं, तो यह pattern हर जगह मिलेगा — जैसे cart items count करना, stock घटाना वगैरह।

Bitwise Operators in Python

Bitwise Operators Binary Numbers (0 और 1) पर काम करते हैं।

शुरुआत में ये थोड़े कठिन लग सकते हैं, लेकिन System Programming, Networking, Cryptography और Performance Optimization में इनका उपयोग होता है।

Python में मुख्य Bitwise Operators हैं—

  • &
  • |
  • ^
  • ~
  • <<

Bitwise AND (&)

a = 5
b = 3

print(a & b)

Output

1

Bitwise OR (|)

print(5 | 3)

Output

7

Bitwise XOR (^)

print(5 ^ 3)

Output

6

Bitwise NOT (~)

print(~5)

Output

-6

Left Shift (<<)

print(5 << 1)

Output

10

Right Shift (>>)

print(10 >> 1)

Output

5

Real-world Uses of Bitwise Operators

Bitwise Operators का उपयोग निम्न क्षेत्रों में किया जाता है—

  • Operating Systems
  • Embedded Systems
  • Image Processing
  • Network Programming
  • Cryptography
  • High Performance Applications

यदि आप केवल Python Beginner हैं, तो Bitwise Operators को Basic Level तक समझना पर्याप्त है।

Common Mistakes Beginners Make

Confusing = with ==

गलत

if age = 18:

सही

if age == 18:

Using and instead of &

Logical Programs में हमेशा and उपयोग करें।

Bitwise Calculations में & उपयोग करें।

 Forgetting Operator Precedence

गलत तरीके से Brackets न लगाने पर Result बदल सकता है।

बेहतर है कि Complex Expressions में Parentheses का उपयोग करें।

Interview Tips 

Python Interviews में अक्सर ये Questions पूछे जाते हैं—

Q1. Difference between and and &?

  • and → Logical Operator
  • & → Bitwise Operator

Q2. Difference between = and +=?

  • = नई Value Assign करता है।
  • += Existing Value में Addition करके Update करता है।

Q3. Why are Assignment Operators useful?

क्योंकि ये Code को Short, Readable और Efficient बनाते हैं।

Part 3


Membership Operators (Membership Operators)

Membership Operators का उपयोग यह जांचने के लिए किया जाता है कि कोई Value किसी Collection (List, Tuple, Set, Dictionary, String आदि) के अंदर मौजूद है या नहीं।

List of Membership Operators

Operatorकाम
inअगर value sequence में मौजूद हो तो True
not inअगर value sequence में मौजूद न हो तो True

Code Example

python
fruits = ["apple", "banana", "mango"]

print("apple" in fruits)       # True
print("orange" in fruits)      # False
print("orange" not in fruits)  # True

String के साथ Example

python
name = "Ankit Kumar"

print("Ankit" in name)      # True
print("xyz" in name)        # False

Real-World Use Case

मान लीजिए आप check करना चाहते हैं कि कोई user की email valid domain से आई है या नहीं:

python
allowed_domains = ["gmail.com", "outlook.com", "yahoo.com"]

email = "ankit@gmail.com"
domain = email.split("@")[1]

if domain in allowed_domains:
    print("Valid email domain ✅")
else:
    print("Invalid email domain ❌")

यह pattern form validation, signup systems, और filtering logic में बहुत काम आता है।

Real-World Examples — सभी Operators एक साथ

चलिए एक practical उदाहरण देखते हैं जहाँ एक साथ कई operators use होते हैं — एक simple Discount Calculator:

python
price = 1500
is_member = True
coupon_code = "SAVE10"
valid_coupons = ["SAVE10", "SAVE20", "FESTIVE50"]

discount = 0

# Membership operator
if coupon_code in valid_coupons:
    discount += 10  # Assignment operator

# Logical + Comparison operator
if is_member and price > 1000:
    discount += 5

final_price = price - (price * discount / 100)  # Arithmetic operators

print(f"Discount: {discount}%")
print(f"Final Price: ₹{final_price}")

Output:

Discount: 15%
Final Price: ₹1275.0

यह example दिखाता है कि real projects में operators अकेले नहीं, बल्कि एक साथ मिलकर काम करते हैं।

Interview Questions on Python Operators

अगर आप Python interviews की तैयारी कर रहे हैं, तो यह questions जरूर practice करें:

  1. / और // में क्या फर्क है?
    / float division देता है, // floor division देता है (decimal हटाकर नीचे की तरफ round करता है)।
  2. == और is में क्या अंतर है?
    == value compare करता है, is memory location (identity) compare करता है।
  3. Python में and और & एक जैसे हैं क्या?
    नहीं। and logical operator है (boolean values के लिए), जबकि & bitwise operator है (bit-level operations के लिए)।
  4. -7 // 2 का output क्या होगा और क्यों?
    Output होगा -4, क्योंकि floor division हमेशा नीचे की तरफ (negative infinity की दिशा में) round करता है।
  5. Python में short-circuit evaluation क्या है?
    जब and में पहली condition False हो, तो Python दूसरी condition check ही नहीं करता। इसी तरह or में अगर पहली condition True हो, तो दूसरी check नहीं होती। इससे performance बेहतर होती है।
  6. in operator dictionary में कैसे काम करता है?
    Dictionary में in by default keys को check करता है, values को नहीं।
python
   d = {"name": "Ankit"}
   print("name" in d)     # True
   print("Ankit" in d)    # False
  1. Chained comparison operators क्या होते हैं?
    Python में आप एक साथ कई comparisons chain कर सकते हैं:
python
   x = 5
   print(1 < x < 10)  # True

Common Mistakes जो Beginners करते हैं

  1. = और == में confuse होना — Assignment के लिए =, comparison के लिए == इस्तेमाल करें।
  2. Boolean logic में and/or की जगह &/| इस्तेमाल करना — यह अलग-अलग purpose के operators हैं।
  3. is को value comparison के लिए इस्तेमाल करना — values compare करने के लिए हमेशा == इस्तेमाल करें, is सिर्फ identity check के लिए है।
  4. Floor division को समझे बिना negative numbers पर इस्तेमाल करना — याद रखें, यह हमेशा नीचे की तरफ round करता है, zero की तरफ नहीं।
  5. Operator precedence को नजरअंदाज़ करना — जैसे 2 + 3 * 4 का output 20 नहीं बल्कि 14 होगा, क्योंकि multiplication पहले होता है। Confusion से बचने के लिए brackets () का इस्तेमाल करें।

Best Practices

  1. Readability के लिए brackets का इस्तेमाल करें — भले ही operator precedence सही हो, complex expressions में () लगाना code को समझने में आसान बनाता है।
  2. Boolean checks के लिए हमेशा and, or, not इस्तेमाल करें, bitwise operators नहीं (जब तक specifically bit-level काम न हो)।
  3. None check करने के लिए is None इस्तेमाल करें, == None नहीं — यह Python की recommended (PEP 8) style है।
python
   if value is None:
       print("Value is empty")

  1. Membership check (in) को loops से बेहतर समझें — जहाँ possible हो, in operator इस्तेमाल करें बजाय manual loop लिखने के।
  2. Assignment operators (+=, -= आदि) का इस्तेमाल code को concise बनाने के लिए करें, लेकिन readability से समझौता न करें।

FAQs (Frequently Asked Questions)

1. Python में कितने प्रकार के operators होते हैं?
Python में मुख्य रूप से 7 प्रकार के operators होते हैं — Arithmetic, Comparison, Logical, Assignment, Bitwise, Identity, और Membership Operators।

  • Arithmetic Operators
  • Comparison Operators
  • Logical Operators
  • Assignment Operators
  • Bitwise Operators
  • Identity Operators
  • Membership Operators

    हर Operator का उपयोग अलग-अलग Programming Situations में किया जाता है।
  • 2. Python में / और // में क्या अंतर है?
    / operator हमेशा float (decimal) value return करता है, जबकि // operator floor division करके decimal हटा देता है और नीचे की तरफ round करता है।

    3. == और is operator में क्या फर्क है?
    == दो values को compare करता है, जबकि is यह check करता है कि दोनों variables memory में same object को point कर रहे हैं या नहीं।

    4. Python में Logical Operators कौन-कौन से हैं?
    Python में तीन Logical Operators होते हैं — and, or, और not

    5. Bitwise Operators का इस्तेमाल कब किया जाता है?
    Bitwise Operators का इस्तेमाल तब होता है जब हमें numbers पर bit-level operations करने हों — जैसे low-level programming, flags manage करना, या performance optimization।

    6. Python में Identity Operators क्यों जरूरी हैं?
    Identity Operators (is, is not) यह पता करने में मदद करते हैं कि दो variables एक ही memory location को point कर रहे हैं या अलग-अलग objects हैं — जो debugging और mutable objects समझने में उपयोगी है।

    7. Membership Operators किन data types पर काम करते हैं?
    Membership Operators (in, not in) list, tuple, string, set, और dictionary जैसे sequences पर काम करते हैं।

    8. and और & में क्या अंतर है?
    and एक logical operator है जो boolean values (True/False) पर काम करता है, जबकि & एक bitwise operator है जो numbers के individual bits पर काम करता है।

    9. Assignment Operators code को कैसे बेहतर बनाते हैं?
    Assignment Operators (+=, -=, *= आदि) code को छोटा और readable बनाते हैं, जैसे x = x + 1 की जगह x += 1 लिखना।

    10. What should I learn after Python Operators?

    Python Operators के बाद आपको निम्न Topics सीखने चाहिए—

    • Python Keywords
    • Data Types
    • Type Casting
    • Input & Output
    • Conditional Statements
    • Loops
    • Functions
    • Lists
    • Dictionaries

    इन्हें सीखने से आपकी Python Foundation और मजबूत होगी।

    Common Interview Questions

    यदि आप Python Interview की तैयारी कर रहे हैं, तो नीचे दिए गए Questions की Practice जरूर करें—

    • What are Python Operators?
    • Explain Arithmetic Operators with examples.
    • Difference between = and ==.
    • Difference between == and is.
    • Explain Logical Operators.
    • What are Assignment Operators?
    • What is Operator Precedence?
    • Explain Membership Operators.
    • What are Bitwise Operators?
    • Which Operators are used in Machine Learning projects?

    Conclusion

    Python Operators, programming सीखने की नींव हैं। चाहे आप एक simple calculator बना रहे हों, या एक पूरा e-commerce system जैसे AnguliMart — हर जगह Arithmetic, Comparison, Logical, Assignment, Bitwise, Identity, और Membership Operators किसी न किसी रूप में इस्तेमाल होते हैं।

    अगर आपने यह पूरा article ध्यान से पढ़ा और examples खुद practice किए, तो अब आप confidently कह सकते हैं कि आपको Python Operators की अच्छी समझ आ गई है। अगला कदम है — इन्हें conditions (if-else) और loops के साथ मिलाकर real programs बनाना, जिससे आपकी concepts और मजबूत होंगी।

    Practice करते रहिए, और अगर कोई doubt हो तो comment में जरूर पूछें! 


    अगर आपने अभी Python सीखना शुरू किया है, तो पहले हमारी Python Kya Hai – Beginner Guide वाली post जरूर पढ़ें।

    Variables की बेसिक समझ के लिए Python Variables in Hindi पढ़ना भी फायदेमंद रहेगा।

    Input लेना और Output दिखाना सीखने के लिए Python Input and Output in Hindi वाली guide जरूर देखें।

    Interview की तैयारी के लिए हमारी Top 100 Python Interview Questions in Hindi पढ़ें।