Answer: Python Puzzler #1900

The answer is D. The program prints:

3 10
What the program prints
Checked by running the program for real.

Why?

Python works out everything on the right first, using the old values: b is 3 and a + b is 10. Then it puts them into a and b at the same time.

Trace table

A trace table follows the program step by step. Here’s this one:

ab
before73
after310

The code again

a = 7
b = 3
a, b = b, a + b
print(a, b)

Try it: change one number in the program and predict the new output before you run it.