Check Your Prediction¶
When you swap the values of two variables such as x
and y
, x
will have the initial
value in y
and y
will have the initial value in x
. If x’s initial value was 6 and y’s
was 2 then after the swap x will have a value of 2 and y will have a value of 6.
Run the code below. Does it correctly swap the values?
Run the code below. Does it correctly swap the values?
Q-2: Explain why the code prints what it does. Why doesn’t it swap the values (x and y both have a value of 2 at the end)?
Feedback¶
Q-3: Please provide feedback here. Please share any comments, problems, or suggestions.
What to do next¶
Click on the following link to go to the post test: Practice Problems
You have attempted 1 of 4 activities on this page