# Teacher Note: Limits of the box analogy¶

In this book we use a labelled box as an analogy for variables. However, this analogy only goes so far. Below are a few of the misconceptions students form when thinking of variables as boxes, compared to how variables actually work:

Boxes can contain more than one value at a time

On the other hand, variables can only contain one value at a time. Take the following sequence of assignment statements:

If the variable name were a box, what does it now contain after these two assignments? This is the correct behavior: “Mary” will replace “Jane” as the value of name. You can verify this by running the above code and observing the output.

However, if the student misapplied the box analogy, she might say that name now contains both “Jane” and “Mary”.

You take an object out of a box before placing it in another

Students may take this prior understanding of boxes and misapply them to variables when dealing with assignment. For example, what is printed out after this running this program?

What happens during the assignment in line 2? The value of name1 is copied into name2. The correct prediction to make is that “Jane” is printed two times.

However, a student may interpret line 2 to mean “take the value in the box name1 and move it to the box name2“. This will leave nothing in name1, leaving it empty. She may predict then that the first print will display nothing, while the second print will display “Jane”. This is incorrect.

Boxes may be a useful analogy to understand variables, but it’s important to highlight that not everything about boxes applies.