Here are the Assignment Operators in Python Language
Assignment Operators are used to assign values to variables. In simple words, putting value in a variable. These values can be of any data type.
Equal to operator is used to assign any value to a variable.
>>> x = 5
>>> name = ‘Mohit’
Here value of 5 (integer) is assigned to variable x
Value of Mohit (String type) is assigned to variable name.
Note – the value to be assigned (defined) should be written on right hand side of = sign.
Here x = 5 is correct but 5 = x is incorrect.
See an example:
>>> a = 65
>>> b = a
>>> u = 65
>>> u = v #Will raise Error
>>> x = 56
>>> x += 56
Here x + = 56 means x = x + 56
>>> g = 58
>>> g -= 8 # g = g-8 | g = 58 – 8
We are assigning a value of g – 8 to g itself.
>>> a = 4
>>> a *= 5 # a = a * 5
>>> df = 45
>>> df /= 5 # df = df / 5