Homework # 9a:  Local and Global Variables

Below are a few simple exercises that will help you understand better some of the basic ideas behind local and global variable.  You may use the Documentation Center to assist you with these problems.

Please format your solutions appropriately.  Use text format, not input format, when you are typing text.  Write coherent sentences and paragraphs;  part of your grade will depend on how clearly you present your ideas.

You must work on these exercises by yourself, not in pairs;  if you get stuck and cannot find the solution in the Documentation Center, you may consult the labbie or the instructor during their office hours.

Local and Global Variables

In Mathematica some variables are local variables and other variables are global variables.  In Module 9a, you made use of both kinds of variables.

Problems

Explain in your own words the distinction between a local variable and a global variable.

Why are local variables useful?  Illustrate your answer with examples.

Why are global variables useful?  Illustrate your answer with examples.

How do you introduce local variables in Mathematica?  Describe at least two methods.

How do you introduce global variables in Mathematica?

Give examples from Module 9a of the use of local variables and the use of global variables.