I’m sure this is a basic question for many here. I only recently began learning and any small question I highlight in my notes; this is the only question I haven’t been able to answer myself yet.

A question I was given in my course:

Given values for x and y, define a variable that sums the two.

The correct answer was [print x = x + y] (without the brackets). But using the operand += also gives the correct answer for any values I could think of.

Is the += only correct here because it’s such a basic example? If so, then in what situation would it not be correct?

Also, a bonus question: Why would my course designers not use a third variable (i.e. z) to sum x and y? I’m assuming they asked me to use x to represent two different expressions for a reason.