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)
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:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers