Prediction

Read the code below and then answer the following question.

# set the initial values of x and y
x = 6
y = 2

# print the values
print("x =", x)
print("y =", y)

# swap the values of x and y
x = y
y = x

# print the values
print("x =", x)
print("y =", y)
    What will the code above print? To save space we are showing all of the answers on one line with a comma between values rather than on different lines.
  • 1. It will print: x = 6, y = 2, x = 2, y = 6
  • 2. It will print: x = 2, y = 6, x = 6, y = 2
  • 3. It will print: x = 6, y = 2, x = 2, y = 2
  • 4. It will print: x = 2, y = 6, y = 6, y = 6
  • 5. None of the above will print.

Feedback

Q-2: Please provide feedback here. Please share any comments, problems, or suggestions.

What to do next

Click on the following link to check your prediction: Check Your Prediction

You have attempted 1 of 3 activities on this page