How datas are stored?can anyome explain how it works.. i got output as 100.. but i expected 1 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How datas are stored?can anyome explain how it works.. i got output as 100.. but i expected 1

a=100 b=a b=1 print(a)

15th Mar 2017, 11:29 AM
Abin Singh R
Abin Singh R - avatar
2 Answers
+ 4
in this case you assign the value of 100 to a variable 'a'. then you assign the value of 'a' (100) to the variable 'b' at this stage both a and b equal 100. then you assign 1 to b so now: a = 100 #you haven't changed the value of 'a' b = 1 # you first made it 100 and then changed it to 1. you then print the value of 'a' which is 100. variable on the left, value bring assigned in the right. Hope that helps!
15th Mar 2017, 11:36 AM
Elric Hindy
Elric Hindy - avatar
+ 2
always in equality expressions : destination var= argument vars so what would You suppose to achieve in such expression: {x=a+b+c;} {a+b+c=x;} is the same as {a+b+x;} VALUE = ARGUMENT i.e. F(x)=ax+b;
15th Mar 2017, 12:15 PM
Michał Bujakowski
Michał Bujakowski - avatar