Python : Operators in Hindi

ऑपरेटर , symbol को define करता है। Operators का उपयोग दो या उससे अधिक operands (variable & values ) के बीच ऑपरेशन को perform करने के लिए किया जाता है।

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

Arithmetic operators

Arithmetic Operators का उपयोग numeric values के साथ common mathematical ऑपरेशन को perform करने के लिए किया जाता है।

OperatorNameExample
+Additionx + y
Subtractionx – y
*Multiplicationx * y
/Divisionx / y
%Modulusx % y
**Exponentiationx ** y
//Floor divisionx // y
A= 50
B= 22
print("Addition :  ", A+B)
print("Subtraction :  ", A-B)
print("Multiplication :  ", A*B)
print("Division :  ", A/B)
print("Modulus :  " , A%B)
print("Exponentiation :  ", A**B)
print("Floor division :  ", A//B)

OUTPUT:
Addition :   72
Subtraction :   28
Multiplication :   1100
Division :   2.272727272727273
Modulus :   6
Exponentiation :   23841857910156250000000000000000000000
Floor division :   2

Assignment operators

Assignment Operators का उपयोग variables को values assign करने के लिए किया जाता है।

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

Comparison operators

Comparison operators का उपयोग दो values को compare करने के लिए किया जाता है।

OperatorNameExample
==Equalx == y
!=Not equalx != y
>Greater thanx > y
<Less thanx < y
>=Greater than or equal tox >= y
<=Less than or equal tox <= y
x = 20
y = 20
print("Equal :  ", x==y)
print("Not equal :  ",x!=y)
OUTPUT 
Equal :   True
Not equal :   False

a=15
b=26
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 
Greater than :   False
Less than :   True
Greater than or equal to :   False
Less than or equal to :   True

Logical operators

OperatorDescriptionExample
and यदि दोनों statements सही है तो यह true return करेगा।x < 5 and  x < 10
orयदि दोनों statements में से एक statements भी सही है तो यह true return करेगा।x < 5 or x < 4
notयह result को reverse करता है अर्थात यदि result false है तो यह true return करेगा।not(x < 5 and x < 10)
x = 20
print("AND Operator :  ", x > 15 and x < 100)
OUTPUT 
AND Operator :   True

x = 20
print("OR Operator :  ", x < 15 or x < 100)
OUTPUT 
OR Operator :   True

x = 20
print("Not Operator :  ", not( x > 15 and x < 100))
OUTPUT
Not Operator :   False

Identity operators

OperatorDescriptionExample
is यदि दोनों variable के पास एक सामान object हो तो यह true return करता है।x is y
is notयदि दोनों variable के पास एक सामान object नहीं हो तो यह true return करता है।x is not y
x = ["Mango", "banana"]
y = ["Mango", "banana"]
z = x
print(x is z)
# return true आएगा क्योकि z और x में एक समान object हैं। 
print(x is y)
#  return False आएगा  क्योकि x और y में एक समान object नहीं हैं। भले ही उनके पास समान content हो। 
OUTPUT
True
False
--------------------------------------------------------------------------------------
print(x is not z)
# return False आएगा क्योकि z और x में एक समान object हैं। 
print(x is not y)
#  return True आएगा  क्योकि x और y में एक समान object नहीं हैं। भले ही उनके पास समान content हो। 
OUTPUT
False
True

Membership operators

OperatorDescriptionExample
in Returns True if a sequence with the specified value is present in the objectx in y
not inReturns True if a sequence with the specified value is not present in the objectx not in y

Bitwise operators

OperatorNameDescription
ANDSets each bit to 1 if both bits are 1
|ORSets each bit to 1 if one of two bits is 1
 ^XORSets each bit to 1 if only one of two bits is 1
NOTInverts all the bits
<<Zero fill left shiftShift left by pushing zeros in from the right and let the leftmost bits fall off
>>Signed right shiftShift right by pushing copies of the leftmost bit in from the left, and let the rightmost bits fall off