0

What does temp means

Exp

18th Sep 2019, 3:53 AM
aniket rajput
aniket rajput - avatar
2 Answers
+ 1
where did you see it? it perhaps was a temporary variable
18th Sep 2019, 4:30 AM
Anton Böhler
Anton Böhler - avatar
+ 1
It is often a variable used to swap value between 2 variables. If a = 5 and b = 8, how would you swap their values? You could try: a = b b = a But then those variables would both equal 8. You could try: b = 5 a = 8 But it is not the searched solution. You can solve this using temp variable. temp = a a = b b = temp Now a = 8 and b = 5 There are some tricks, which make it unecessary to use temp. In Python you could just solve it like this: a, b = b, a Now a = 8, b = 5 But here is the trick: a = b + a b = a - b a = a - b Now a = 8, b = 5
18th Sep 2019, 4:38 AM
Seb TheS
Seb TheS - avatar