Table of Contents

Assignment Operators

Assignment operators are used to assigning values to variables.

Operator Same As Example
= x = 5 x = 5
+= x = x + 3 x += 3
*= x = x * 3 x *= 3
-= x = x – 3 x -= 3
/= x = x / 3 x /= 3
%= x = x % 3 x %= 3
//= x = x // 3 x //= 3
**= x = x ** 3 x **= 3
&= x = x & 3 x &= 3
|= x = x | 3 x |= 3
^= x = x ^ 3 x ^= 3
>>= x = x >> 3 x >>= 3
<<= x = x << 3 x <<= 3
Example

Addition of two number

x = 8
y = 3

print(x + y)
Output
11