Python | Operator | Assignment Operators By. Shivansh Sir
PYTHON PROGRAMMING
PYTHON | ASSIGNMENT OPERATOR
Source Code
a = 3
b = 4
c = a + b
print(c)
Output
7
PYTHON | ASSIGNMENT OPERATOR | ADD ASSIGNMENT
Source Code
a = 3
c = 6
c += a #c = c + a
print(c)
Output
9
PYTHON | ASSIGNMENT OPERATOR | SUBTRACT ASSIGNMENT
Source Code
a = 3
c = 6
c -= a #c = c - a
print(c)
Output :
3
PYTHON | ASSIGNMENT OPERATOR | MULTIPLY
Source Code
a = 3
c = 6
c *= a #c = c * a
print(c)
Output
18
PYTHON | ASSIGNMENT OPERATOR | DIVIDE
Source Code
a = 3
c = 6
c /= a #c = c / a
print(c)
Output
2.0
PYTHON | ASSIGNMENT OPERATOR | MODULUS
यहाँ पर 'c' variable को 'a' variable से divide करके उनका remainder return करके 'c' variable पर store किया जाता है |
Source Code
a = 3
c = 6
c %= a #c = c % a
print(c)
Output
0
PYTHON | ASSIGNMENT OPERATOR | EXPONENT
यहाँ पर 'c' variable का power 'a' variable है और उनकी value 'c' variable में store की गयी है |
Source Code
a = 3
c = 6
c **= a #c = c ** a
print(c)
Output
216
PYTHON | ASSIGNMENT OPERATOR | FLOOR DIVIDE
यहाँ पर 'c' variable को 'a' variable से divide करके उनकी floor value 'c' variable पर store की गयी है |
Source Code
a = 3
c = 6
c //= a #c = c // a
print(c)
#same as
import math
a = 3
c = 6
c = math.floor(c/a)
print(c)
Output
2
2
PYTHON | ASSIGNMENT OPERATOR | BITWISE OPERATOR
1. Bitwise AND (&)
2. Bitwise OR (|)
3. Bitwise XOR (^)
4. Bitwise Complement (~)
ये Operator सारे bit reverse करता है | ये Operator 0 को 1 कर देता है और 1 को 0 कर देता है |
5. Bitwise Left Shift (<<)
Left Shift(<<) for e.g. a=20; /* 0001 0100 */ a << 2 में numeric value के binary value में हर binary number को 2 binary numbers left side से shift करता है | for e.g. a=20; /* 0001 0100 */ तो इसका 0101 0000 मतलब 80 हो जायेगा |
6. Bitwise Right Shift (>>)
Right Shift(>>) for e.g. a=20; /* 0001 0100 */ ये Left shift से बिलकुल उलट है | Right Shift a>> 2 में numeric value के binary value में हर binary number को 2 binary numbers right side से shift करता है | for e.g.a=20; /* 0001 0100 */ तो इसका 0000 0101 मतलब 5 हो जायेगा |
Comments
Post a Comment