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.
Before you keep reading...
Making great stuff takes time and $$. If you appreciate the book you are reading now and want to keep quality materials free for other students please consider a donation to Runestone Academy. We ask that you consider a $10 donation, but if you can give more thats great, if $10 is too much for your budget we would be happy with whatever you can afford as a show of support.
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