The Assignment Dry Run Activity

Dry run on paper simple programs that involve variables and assignment.

Set a series of dry run exercises where students have to step through short fragments of code, working out what they do, on paper. This is an important activity to do after explaining variables and assignment. It reinforces understanding and helps identify faulty mental models so they can be fixed. Being able to do this kind of dry run for any new construct is an important prerequisite to being able to actually write code.

Fixing faulty mental models

Mark the dry runs on the spot. If any student is making more than just simple slips, so has a faulty understanding sit down with them and do one exercise as a dry run (see below) in front of them. Explain what you are doing step by step – so what the computer is doing. Chances are they will then tell you what they had misunderstood. Then make the student do the next one in front of you. You will spot which faulty mental model they have, if they are still confused. Explain what they have misunderstood and have them redo the remaining exercises drawing dry run tables. Chances are they will now get them all right (and have a better understanding of the concepts).

Dry Run Tables

Teach students to solve this kind of dry run problem by drawing a dry run table. This reinforces the semantics of the concepts which is the most important thing (not the syntax).

For each variable declared/created add a new column to the table. When a variable is assigned to, cross out any old value in the column and replace it by the new value. Whenever you need to find the value of a variable, look up the last value placed in its column (do not look at the program to find current values!)

You can also include columns for what is printed at a step and if it helps add a line column. For more complicated concepts like if statements and loops having a column for the value of each boolean expression helps too.

By doing this you are acting out being a computer executing the program, and in doing that you reinforce what the concepts are.

Learn about:

  • programming
  • assignment
  • variables
  • values
  • declaration
  • initialisation
  • sequencing

Resources
This session comes with linked activity sheets and ‘story’ write-ups that you can download:

Dry Run Table Puzzles / Diagnostic Tests

Activity Booklets

This activity can be done on its own but naturally combines with the Box Variable activity.

Back to activities

One thought on “The Assignment Dry Run Activity

  1. Pingback: SEMANTIC WAVES | Teaching London Computing: A RESOURCE HUB from CAS LONDON & CS4FN

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.