- 1

What are The Differences between these?

I'm a beginner, i wanna understand the logic of programming, my question is what is the difference between these in terms of the size of the file? ---------------- 1) a = 2 b = 3 print a + b ----------------- 2) Print 2 + 3 ----------------- 3) a = 2 b = 3 c = a + b print c ------------

12th Jul 2017, 9:56 AM
peshang
peshang - avatar
3 Respostas
+ 8
The second case is not efficient, as if at write time you can put litterals, you can even calculate it and write instead: print(5) # in Python3 parenthesis (rounded brackets) are mandatory Anyway, between first and last case, it depends if you need later the calculated value: in such case, last case is more efficient, else it's the first one... But related to file size, the lesser is just the one wich have the less characters, as Python isn't compiled ^^
12th Jul 2017, 10:17 AM
visph
visph - avatar
+ 1
1) You can change the variables later in the code to print a different sum. 2) Or to print 2637 + 30558, just to be sure it's still = 33195. 3) Is the standard scenario. Where you keep the sum of two variables in the third.
12th Jul 2017, 11:28 AM
Boris Batinkov
Boris Batinkov - avatar
0
Thank to you both, I didn't really think it was like that, it makes sense now
12th Jul 2017, 11:30 AM
peshang
peshang - avatar