Assignment operators assign values to variables. Compound assignment operators will take a variable as input, do arithmetic on it and then assign the result back to the variable.
syntax
Operator
Name
Description
Example Syntax
Example Result
=
assignment operator
assign value to variable
var = 10
var = 10
+=
compound add
add variable to operand and assign result to variable
var += 10
var = var + 10
-=
compound subtract
subtract variable from operand and assign result to variable
var -= 10
var = var - 10
*=
compound multiply
multiple variable by operand and assign result to variable
var *= 10
var = var * 10
/=
compound divide
divide variable by operand and assign result to variable
var /= 10
var = var / 10
%=
compound modulo
divide variable by operand and assign remainder to variable
var %= 10
var = var % 10
**=
compound exponent
raise variable to power of operand and assign result to variable
var **= 10
var = var ** 10
//=
compound floor divide
divide variable by operand and assign result without decimals