Assignment Operator#
Assignment operators are used to assign and update values to variables.
See definition:
Operation |
Operator |
Examples |
---|---|---|
Assignment Operator |
|
|
Multiplication Assignment |
|
|
Division Assignment |
|
|
Addition Assignment |
|
|
Subtraction Assignment |
|
|
Remainder Assignment |
|
|
Exponent Assignment |
|
|
Examples
# Define a variable "var_a" by assigning 10
var_a = 10
# assign the multiplication of var_a by 3
var_a *= 3
print(var_a)
30
# assign the division of var_a by 3
var_a /= 2
print(var_a)
15.0
# assign the subtraction of var_a by -5
var_a -= 5
print(var_a)
10.0
# assign the exponent of var_a by 2
var_a **= 2
print(var_a)
100.0