Python Programming - Variables - Discussion

Discussion Forum : Variables - General Questions (Q.No. 22)
22.
What is the output of the following code:
x = 10
y = 5
x, y = y, x
print(x, y)
5 10
10 5
An error is raised
None of the above
Answer: Option
Explanation:

In this code, two variables x and y are assigned the values 10 and 5 respectively.

The third line swaps the values of the variables using the tuple packing and unpacking technique.

When the variables are printed to the console, the output is 5 10.

Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.