Assignment Operator

Assignment Operator
Sign
Example
Same as
Assignment
=
z= x +y

Addition Assignment
+=
z+=x
z=z +x
Subtract Assignment
-=
z-=x
z=z-x
Multiple Assignment
*=
z*=x
z=z*x
Divide Assignment
/=
z/=x
z=z/x
Modules Assignment
%=
z%=x
z=z/x
Exponent Assignment
**=
z**=x
z=z**x
Floor divide Assignment
//=
z//=x
z=z//x
Bitwise AND Assignment
&=
z&=x
z=z &x
Bitwise OR Assignment
|=
z|=x
z=z |x
Bitwise XOR Assignment
^=
z^=x
z=z ^x
Bitwise Left Shift
Assignment
<<=
z<<=x
z=z<<x
Bitwise Right        ShiftAssignment

>>=
z>>=x
z=z>>x
Add caption

Assignment Operator


Source Code:

a = 10
b = 17
c = a + b
print (c)
Output:

27


Add Assignment Operator in Python

Source Code:

a = 10
c = 19
c + = a
print (c)

Output:
29


Subtract Assignment Operator in Python

Source Code:

a = 7
c = 10
c - = a
print (c)

Output:
3


Multiply Assignment Operator in Python

Source Code:

x = 3
z = 6
c * = a
print (c)

Output:
18


Divide Assignment Operator in Python

Source Code:

a = 6
c = 3
c / = a
print (c)

Output:
0.5


Modulus Assignment Operator in Python

Here the 'c' variable is divided by 'a' variable and their remaining return is stored on 'c' variable.

Source Code:

a = 3
c = 6
c% = c
print (c)

Output:
0


Exponent Assignment Operator in Python

Here the power of 'c' variable is 'a' variable and their value is stored in 'c' variable.

Source Code:

a = 3
c = 6
c ** = a
print (c)

Output:
216