Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
What does this program show?
Copying a value into b does not tie b to a. Later changes to a do not change b.
Have you tried it?
Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, compare your working with the solution.
Follow the program one line at a time.
x = 10, so the first print(x) shows 10.x = x - 4 takes the old value 10, subtracts 4 and stores 6. The second print(x) shows 6.a = 5. Then b = a copies the value 5 into b.a = 9 changes only a. The variable b still holds 5.print(a, b) shows 9 5.Answer: 10, 6 and 9 5.
Log in to join the discussion.
Loading…