+ 2
a=5 b=a a=4 print(b) What is output and why :)
10 ответов
+ 9
the output will be 5
because the value of b was assigned then after the value of a is changed so the value of b not change
+ 4
The output will be: 5
since, value of a(5) is assigned to b.
after assigning b the value of a is changed so it will not be updated in b.
+ 2
значение из переменной справа от равно, уходит в переменную слева от равно)
т.е. слева от равно стоит приёмник значения
+ 2
answer will be 5 because before assigning a new value to a the older value was stored in b.The program executes from top to bottom.
+ 2
The output will be 5
Simply, it's like first "a" becomes 5, then "b" becomes "a" ie "b" now becomes 5. Nothing is said about "b", so" b"remains "b".
Next part of the story is" a" becomes 4. Nothing about "b".
The thing is, python won't remember the previous line once executed.
We can say it won't hold grudges, fresh start every time you want to assign a value to the variable, it doesn't really haunts it's past, simply new identity is given.
Hope it helps, kinda childish but with good intention :)
+ 1
Basically, program runs from left to right and top to bottom. So the answer will be 5 here.
0
The output will be: 5
since, value of a(5) is assigned to b.
after assigning b the value of a is changed so it will not be updated in b.
- 1
hello
- 1
wow its good question!
- 1
Neat little puzzle to get someone (like me) unused to thinking this way a bit of exercise, nice :)