+ 5

Why the output is 2?

a=2 b=3 c=4 d=5 d=a a=b b=c c=d print(c)

11th Aug 2017, 8:59 AM
Joseph Franjieh
Joseph Franjieh - avatar
4 Answers
+ 4
in the logical math field there is a property called the Transitive Property, it means that when a list of things are equal to one another then the extra equalities will be equal. example. a = b, b = c :. a = c. in the problem it requests c which is c = d, which d = a, and a = 2. you might ask what about the former listings of d = 5 and c = 4. I am also unsure of the output, it could be that the list will take values transtively and in ascending order.
11th Aug 2017, 1:06 PM
killerman64
killerman64 - avatar
+ 12
print(c), so we backtrack the value of c. d was assigned to c, and a was assigned to d. a was initialised to 2, so c would end up holding the value of a, which is 2.
11th Aug 2017, 9:03 AM
Hatsy Rei
Hatsy Rei - avatar
+ 2
bcoz d assigned its value of a so when c assigns d value ,it will be 2
12th Aug 2017, 4:08 AM
Kumuda
Kumuda - avatar
+ 1
see this code match each output with corresponding print line.... https://code.sololearn.com/ctkc3O57d9P1/?ref=app
11th Aug 2017, 12:28 PM
sayan chandra
sayan chandra - avatar