trace the code
100

What is printed when this code runs?

x = 3

y = x + 2

print(y) 

 5


 x is set to 3.
 y becomes 3 + 2, which is 5.
 The program prints the value of y.

200

What is the final output of this code?

total = 0

for i in range(1, 4):

    total = total + i

print(total)

6

 The loop runs with i = 1, 2, 3.

  • After first loop: total = 1

  • After second loop: total = 3

After third loop: total = 6

300

What is printed when this code runs?

def mystery(n):

    if n <= 1:

        return n

    return n + mystery(n - 1)

print(mystery(4))

 10