+ 2

Can someone explain this problem

a = 5 b = 7 c= b = a print(a) print(b) print(c) Here, every variable's value is coming 5. Why is it like that. It could be 7, why only 5

24th Jul 2020, 7:39 AM
<k>Kartik</k>
6 Respuestas
+ 3
Variable gets the value assigned on the right. In this case, however, it starts from the far right.
24th Jul 2020, 7:48 AM
JaScript
JaScript - avatar
+ 3
When u wrote : c = b = a It works like this c = (b = a) a = 5 so b = 5 Then c = 5 That's why every variable outputs 5
24th Jul 2020, 7:52 AM
MSN
MSN - avatar
+ 2
C=b=7 B=a=5 C=a=5 Here a=5 B=5 C=5 kartik dhingra
24th Jul 2020, 7:41 AM
Sâgærāvürï
Sâgærāvürï - avatar
+ 1
A assign in b&c
25th Jul 2020, 4:04 AM
Amit
Amit - avatar
+ 1
U write: C=b=a It read as C=(b=a) As per the priority order of different operators , parentheses (),have highest priority So, A=B=C=5
25th Jul 2020, 9:54 AM
S.Gopi Reddy™🔵
S.Gopi Reddy™🔵 - avatar