Determine the output of the following code.
It counts as cheating if you run the code!
The computer first runs x = [2, 4, 8]. This tells the computer to take x and point it to the array, so we get the following picture:
Next, the computer runs y = x. It takes y and points it wherever x points.
Next, the computer runs x[0] = 1. It takes x[0] and points it to the number 1.
Finally, the computer runs print(y[0]). The computer steps to the y, and then along the 0 pointer, and prints out 1.
This result might have been surprising, since we changed x[0], and then y[0] also changed at the same time. But it's clear why this happened if you understand how pointers work in Python.