Computer >> Computer tutorials >  >> Programming >> Python

What are different assignment operators types in Python?


Following table shows all assignment operators −

Operator Description Example
= Assigns values from right side operands to left side operand c = a + b value of a + b into c
+= It adds right operand to the left operand and assign the result to left operand c += a add a into c
-= It subtracts right operand from the left operand and assign the result to left operand c -= a subtract a from c
*= It multiplies right operand with the left operand and assign the result to left operand c *= a multiply c by a and assign to c
/= It divides left operand with the right operand and assign the result to left operand c /= a divide c by a and assign to c
%= It takes modulus using two operands and assign the result to left operand c %= a assign remainder of c/a to c
**= Performs exponential (power) calculation on operators and assign value to the left operand c **= assign c raised to a to c
//= It performs floor division on operators and assign value to the left operand c //= a floor division of c/a assigned to c