Basic Operators in Python

Python में operators ऐसे symbols होते हैं जिनकी मदद से values और variables पर अलग-अलग प्रकार के operations किए जाते हैं।
सरल शब्दों में, operator वह चिन्ह होता है जो दो values के बीच कोई काम करता है, जैसे जोड़ना, घटाना, तुलना करना या value assign करना।

उदाहरण के लिए:

a = 10
b = 5
print(a + b)

यहाँ + एक operator है, जो addition कर रहा है।

Programming में operators बहुत important होते हैं, क्योंकि calculations, comparisons और logic building इन्हीं की मदद से होती है।

Operators के मुख्य प्रकार

Python में beginners level पर ये operators सबसे important होते हैं:

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

अब इन्हें एक-एक करके examples और code के साथ समझते हैं।

Arithmetic Operators

Arithmetic operators का use mathematical calculations के लिए किया जाता है।

इनमें मुख्य operators हैं:

  • + → Addition
  • - → Subtraction
  • * → Multiplication
  • / → Division
  • % → Modulus
  • ** → Exponent
  • // → Floor Division

Example

मान लीजिए:

a = 10
b = 3

अब हर operator का use देखते हैं।

Addition

a = 10
b = 3
print(a + b)

Output:

13

Subtraction

a = 10
b = 3
print(a - b)

Output:

7

Multiplication

a = 10
b = 3
print(a * b)

Output:

30

Division

a = 10
b = 3
print(a / b)

Output:

3.3333333333333335

Modulus

यह remainder देता है।

a = 10
b = 3
print(a % b)

Output:

1

Exponent

यह power निकालता है।

a = 2
b = 3
print(a ** b)

Output:

8

Floor Division

यह quotient का integer part देता है।

a = 10
b = 3
print(a // b)

Output:

3

Combined Example

a = 10
b = 3
print("Addition =", a + b)
print("Subtraction =", a - b)
print("Multiplication =", a * b)
print("Division =", a / b)
print("Modulus =", a % b)
print("Exponent =", a ** b)
print("Floor Division =", a // b)

Output:

Addition = 13
Subtraction = 7
Multiplication = 30
Division = 3.3333333333333335
Modulus = 1
Exponent = 1000
Floor Division = 3

Comparison Operators

Comparison operators का use दो values को compare करने के लिए किया जाता है।
इनका output हमेशा True या False होता है।

मुख्य comparison operators हैं:

  • == → Equal to
  • != → Not equal to
  • > → Greater than
  • < → Less than
  • >= → Greater than or equal to
  • <= → Less than or equal to

Example

x = 5
y = 8
print(x == y)
print(x != y)
print(x > y)
print(x < y)
print(x >= y)
print(x <= y)

Output:

False
True
False
True
False
True

Explanation

  • x == y → check करता है कि दोनों equal हैं या नहीं
  • x != y → check करता है कि दोनों अलग हैं या नहीं
  • x > y → check करता है कि x बड़ा है या नहीं
  • x < y → check करता है कि x छोटा है या नहीं

Real Example

marks = 40
passing_marks = 33
print(marks >= passing_marks)

Output:

True

इसका मतलब student pass है।

Assignment Operators

Assignment operators का use variable में value store करने के लिए किया जाता है।

सबसे basic assignment operator है:

  • = → Assign value

Example

x = 10
print(x)

Output:

10

इसके अलावा short assignment forms भी होती हैं:

  • +=
  • -=
  • *=
  • /=
  • %=
  • //=
  • **=

Example

x = 10
x += 5
print(x)

Output:

15

और examples

x = 10
x -= 2
print(x)

Output:

8
x = 10
x *= 3
print(x)

Output:

30
x = 10
x /= 2
print(x)

Output:

5.0

Combined Example

x = 20x += 5
print("After += :", x)x -= 3
print("After -= :", x)x *= 2
print("After *= :", x)x //= 4
print("After //= :", x)

Output:

After += : 25
After -= : 22
After *= : 44
After //= : 11

Logical Operators

Logical operators conditions को combine करने के लिए use होते हैं।

मुख्य logical operators हैं:

  • and
  • or
  • not

Example of and

x = 10
print(x > 5 and x < 20)

Output:

True

यहाँ दोनों conditions true हैं, इसलिए answer true है।

Example of or

x = 10
print(x < 5 or x < 20)

Output:

True

यहाँ एक condition true है, इसलिए answer true है।

Example of not

x = 10
print(not(x > 5))

Output:

False

क्योंकि x > 5 true है, और not उसे false बना देता है।

Real Example

age = 18
citizen = True
print(age >= 18 and citizen)

Output:

True

Bitwise Operators

Bitwise operators numbers के binary form पर काम करते हैं।
Beginners level पर इनका basic idea समझना काफी होता है।

मुख्य bitwise operators हैं:

  • & → AND
  • | → OR
  • ^ → XOR
  • ~ → NOT
  • << → Left Shift
  • >> → Right Shift

Example

a = 5
b = 3
print(a & b)
print(a | b)
print(a ^ b)

Output:

1
7
6

इन operators का use advanced programming और low-level logic में ज्यादा होता है।

Membership Operators

Membership operators यह check करते हैं कि कोई value किसी sequence में मौजूद है या नहीं।

मुख्य operators हैं:

  • in
  • not in

Example

name = "Python"
print("P" in name)
print("z" in name)
print("z" not in name)

Output:

True
False
True

List example

numbers = [1, 2, 3, 4, 5]
print(3 in numbers)
print(10 not in numbers)

Output:

True
True

Identity Operators

Identity operators यह check करते हैं कि दो variables same object को refer कर रहे हैं या नहीं।

मुख्य operators हैं:

  • is
  • is not

Example

x = [1, 2, 3]
y = x
z = [1, 2, 3]
print(x is y)
print(x is z)
print(x is not z)

Output:

True
False
True

यह topic beginners के लिए थोड़ा advanced लग सकता है, लेकिन basic level पर इतना समझना काफी है कि is memory identity check करता है, value equality नहीं।

Arithmetic और Comparison का mixed example

a = 15
b = 4
sum = a + b
difference = a - b
product = a * b
print("Sum =", sum)
print("Difference =", difference)
print("Product =", product)
print("Is sum greater than product?", sum > product)

Output:

Sum = 19
Difference = 11
Product = 60
Is sum greater than product? False

इस example से यह समझ आता है कि operators को एक ही program में साथ use किया जा सकता है।

User Input वाला example

a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
print("Addition =", a + b)
print("Subtraction =", a - b)
print("Multiplication =", a * b)
print("Greater number check =", a > b)

यदि input हो:

8
3

तो output होगा:

Addition = 11
Subtraction = 5
Multiplication = 24
Greater number check = True

यह program operators का practical use दिखाता है।

Students कौन-सी common mistakes करते हैं

Basic operators पढ़ते समय students अक्सर कुछ common mistakes करते हैं।

सबसे पहली गलती = और == में confusion की होती है।
= assignment के लिए होता है, जबकि == comparison के लिए होता है।

दूसरी गलती / और // में होती है।
/ normal division देता है, जबकि // floor division देता है।

तीसरी गलती logical operators में होती है, जहाँ and और or को बिना समझे use कर लिया जाता है।

इसीलिए operators को केवल याद करना नहीं, बल्कि examples के साथ समझना जरूरी है।

इस topic की मुख्य बात

Basic Operators programming के सबसे important building blocks हैं।
इन्हीं की मदद से calculations, comparisons, conditions और logical decisions किए जाते हैं।

Python में beginners level पर सबसे important operators हैं:

  • Arithmetic Operators
  • Comparison Operators
  • Assignment Operators
  • Logical Operators

इनको examples और code के साथ अच्छे से समझ लेना आगे की programming के लिए बहुत जरूरी है।

Leave a Comment

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

Scroll to Top