M&C1: Variables used in programs work like variables in math

If a student is being introduced to computer programming after they have taken a course in algebra, it is common that they will struggle with the transition to using variables to store temporary information. To help them move past this, demonstrate programming statements that violate algebraic rules and emphasize the following process.

  1. Substitute all of the variables on the right hand side with the values that are currently stored in each.
  2. Evaluate the expression according to the order of operations.
  3. Demonstrate the assignment step by writing the statement with just the variable on the left and a single value on the right.

Python example: Following the code segment is how one might write the steps to execute this code on the board for the students

a = 3

b = 5

a = a + b

Write this first:                                     a = a + b

Write this next:                                    a = 3 + 5

Write this last:                                      a = 8