change_me = 2 # Use the shorthand to multiply change_me by 3 and store the result in change_me change_me *= 3 # 6 # Now add 10 to change_me change_me += 10 # 16 # Subtract 4 from change_me change_me -=4 # 12 # Divide change_me by 2 change_me /= 2 # 6
Using the shorthand
Experienced programmers tend to try and type as little as possible to accomplish their goals (so long as it is readable).
As a result, it's important for you to be familiar with and use the shorthand for when you have a variable and you are performing a math operation on itself!
var += 1 is shorthand for var = var + 1
var -= 3 is shorthand for var = var - 3
var *= 5 is shorthand for var = var * 5
var /= 2 is shorthand for var = var / 2
Use this shorthand to follow the steps in the comments to perform the math operations on the variable 'change_me'.
test shorthand - Run Test
def test_shorthand(): assert change_me == 6