Yes Its like magic, isn't it?

This is the point of a "variable". It's a "variable"! That is, its not constant, it changes, it varies. At any given time in the program, variableResistancecontains some value, but the value it contains depends on either where you are in the program or what the user entered, or what was read from a file, or what was read from a socket, etc.

A lot of Computer Science (and therefore programming, as it is) comes from other fields, including mathematics. For example, the functiononlya subfield of Computer ScienceIs a function named "f", taking parameter named "x" of (implicit) type "real number". The body of the function returns some calculation, namely "5x + 2". The result of this of course depends on and requires knowing what the value of "x" is. If "x" is 1 (say, the user input), the result is 7.Code:f(x) = 5x + 2