Q:

Functions using global variables as inputs

So, I'm writing some python scripts and I have some code like the one shown below:
a = 3
dict = {"run":runMiles(a)}
a = 5

The runMiles func takes one variable that is an int. For some reason when dict["run"] is called, the variable doesn't seem to use the "new" variable. It is important to realize that both a and dict are global variables

A:

It does so because the function runMiles() executes at the time this line dict = {"run":runMiles(a)} executes and when you call dict["run"] it will only give the return value got after execution of the function and does not execute the function again to fetch the value of "run" and thus the value does not get updated.

