## The Nature of Variables for Students vs. Programmers

Dan Meyer has provoked us again with this post questioning the meaning of variables in programming compared with how they exist in the minds of our students.

I previously wrote about something I tried at the beginning of last year with my students that probed this question a bit. My contention then was that writing expressions is something that occurs with students only in math class world, and that it is an inherently non-interactive process. The spirit of what variables do is something with which students have familiarity. It’s the abstraction of the mathematical representation that pushes that familiarity away from them.

I’m going to use a different expression problem since the one in Dan’s post doesn’t do it for me.

## Dan estimates that around 3/4 of any group of people drink soda.

I’d start with this activity that students would be able to answer:

Students could each click on the people go through the process of figuring out how many in each group drink soda according to Dan’s estimate, and would record the number in each group. The third group serves to construct a bit of controversy for discussion purposes. In doing this four times, students are presumably going through a similar process each time.

Mathematics serves to create structure for this repetition, but on its own, is not necessarily in the realm of what our students would do to manage this repetition. Programming provides a way to bridge this gap using the same idea of variables that exists in the mathematical realm, and here is where the value sits for this discussion.

In the post I mentioned previously, I said that I briefly showed students how to type expressions into a spreadsheet and play around with inputs and outputs so that they match concrete values. In a non 1:1 laptop classroom, I might start with this:

A calculation links the outputs to the inputs in each of these tables. Students have concrete values sitting in front of them, so they will notice that each of these tables must be making the wrong calculations, even though they each have one correct value. Here, we have the computer making the same calculation each time, but these calculations do not work in each case. This is the wrong *model* to match our data. The computer is doing exactly what we are telling it to do, but the model is wrong.

How do we fix this, class? Obviously we use a different computational model. I might have students decide in a group what calculation I need to do to correctly reproduce the values from the exercise, and elicit those suggestions from them.

Once we establish this correct model, this calculation we are making is common to every set of data. We can show that this calculation makes an interesting prediction of 7.5 people liking soda in the group of 10. We can use this calculation to predict how many people in a group of 28 drink soda (and in a 1:1 classroom, I’d have them go through this entire programming process themselves.)

I might now generate a table hundreds of entries long and ask whether there is a better way to represent the set of all possible answers to this question. The table will work, but it is tedious. We need a better way. How do we do this? Here is where variables come in.

Programmers use variables because they want to build a program that produces a correct output for *every* possible input that might be used to solve a given problem or design. Mathematicians also want to have the same level of universality, and have a syntax and structure that allows for __efficient__ communication of that universality. Computers are really good at calculating. The human brain is really good at managing the abstraction of designing those calculations. This, ultimately, is what we want students to be able to do, but they often get lost in __both__ the design stage and the calculation stage, especially because these get divorced from the actual problem students are trying to solve.

If we can have students spend more time in the design stage and get feedback on whether their calculations are correct, that’s the sweet spot for making the jump to using mathematical variables.