Computer Science, asked by royayandeep147, 7 months ago

what is y Displayed in the following code
x = 1
y = x = x + 1
print("y is",y)​

Answers

Answered by Anonymous
2

Answer:

output of this code will be

y is 2

Answered by aniketdas7217
0

Answer:

Nothing will be output unless you give a print command.

If in python print(x) gives 6

Print (y) gives 4

Print(x,y) gives 6 4

It's easy to understand this way in programming.

Variables are like boxes,and the values on right hand sides are like things in boxes.

First you told computer that x= 2 and y= 6

Then you told x= y

Remember that all right hand side of = deals with values so x= 6

Then y = x+2 = 2+2 = 4

Here you may ask why I didn't take x as 6

In the command you gave x,y= y,x+2

You used , to merge two assignments

So they do that simultaneously meaning at the same time

Comment if I'm wrong:)

Similar questions