Below is the coding that I was writing for Python language,
x = y = z = 3.5
x = 3
print(x)
print(y)
print(z)
The answer is 3 3.5 3.5
CodePudding user response:
x = y = z = 3.5 is one expression assigning 3.5 to x, y, and z. x = 3 is a second expression, assigning a value of 3 only to x. Thus only x has been changed from the initially assigned value of 3.5.
CodePudding user response:
All you have done here is assign the values of x, y, and z to 3.5.
You then adjusted x to 3. y and z still equal 3.5.
So, in order:
x = 3
y = 3.5
z = 3.5
Which is the correct output.
