Python - Augmented Assignment Operators
CBSE Class 11 - Informatics Practices
Python provides augmented assignment operators, which combine the impact of an arithmetic operator with an assignment operator.
e.g. If you want to add value of b to a and then assign the result to a i.e. a = a + b can be written as
a += b
Various augmented operators are:
Operation | Description |
---|---|
x += y | x = x + y |
x -= y | x = x - y |
x *= y | x = x * y |
x /= y | x = x / y |
x //= y | x = x // y |
x **= y | x = x ** y |
x %= y | x = x % y |
x &= y | x = x & y |
x |= y | x = x | y |
x ^= y | x = x ^ y |
x >>= y | x = x >> y |
x <<= y | x = x << y |