What gets printed:
a = b = [1, 2, 3]
b[2] = 4
print(a)
Explanation
Variables a and b are lists in this example. But they point to the same memory area.
Python list datatype is mutable (meaning that it can be modified in place).
Since both variables point to the same data and it can be modified in place, then after variable b is updated, variable a will change as well.

I think the answer is 1,4,3.

2022 Jan 17, 5:21:01 PM

I think the answer is 1,4,3.

2022 Jan 17, 5:20:31 PM

Eu acho que a resposta é 1,4,3.

2022 Jan 17, 5:20:25 PM

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
Python quizzes
Cosmo
Sign Up Now
or Subscribe for future quizzes