Python Programming - Variables - Discussion

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

In this code, a variable x is assigned the value 5, and a variable y is assigned the same value by copying the value of x.

The value of x is then changed to 10, but the value of y remains unchanged at 5.

When the value of y is printed to the console, the output is 5.

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

Post your comments here:

Your comments will be displayed after verification.