0
Whats the output of the code
x=1 y=2 x=y y=x x=y+x print(y) 【answer is 2】
3 Réponses
+ 3
x = 1 x is assigned the value 1
y = 2 y is assigned the value 2
x = y x is assigned the value of y right now which is 2, so x is assigned the value 2
y = x y is assigned the value of x right now which is 2, so y is assigned the value of 2. (Note: y was already 2)
x = y + x x is assigned the value of y + x which is 2 + 2 which is 4, so x is assigned the value 4
print (y) The value of y which is 2 is printed.
So, the output is 2!
+ 3
you'ee welcome!
+ 1
thanks S.C.👌. very well explained