Unit 9 · Lesson 4
Build the idea
Start with the concept and its key vocabulary.
Variables created inside a sub-program are local: they can be used only within that sub-program and are removed when it finishes. Parameters are local too. A global variable is declared in the main program. ERL marks it with global; Python uses global inside a function when that function changes the global value. Prefer parameters and returned values because widespread global state is harder to debug.
The part of a program in which a variable can be accessed.
A variable created inside a sub-program and accessible only there.
A variable declared outside sub-programs and accessible throughout the program.
The time for which a variable exists in memory.