The State Sequence Table Question Type

This page shows a new work-in-progress question type that we have introduced into our introductory programming course, COSC131, at the University of Canterbury. The question type aims to address the problem that many students have only a fuzzy idea of the state of a program and don't seem to be following the detailed step-by-step change of state as the program executes. 

The question type uses the HTML-UI and presents an OK interface to the student, but authoring of questions is currently very cumbersome. A software-engineering student in Belgium is looking into making authoring easier.

Here is the current version (1 October 2023) prototype of the SST question type. While you're welcome to use it, please be aware that it is almost certain to change in the future, though there's no reason to assume that this version will stop working. https://coderunner.org.nz/pluginfile.php/25144/mod_page/content/13/PROTOTYPE_python3_state_sequence_table-20231001-1803.xml

 

Introducing State Sequence Tables [Intro given to students]

When you write a program you're instructing the Python engine what to do. We can think of the Python engine as some sort of robot, and for the rest of this info panel we'll use the term "robot" and "Python engine" interchangeably.

If the robot is to behave the way you want it to, you'd better know exactly how it will interpret each of the instructions (statements) you give it in your program. So bear with us while we focus in some detail on exactly how our robot behaves when a trivial program to execute.

The concept of robot (program) state

We will describe the behaviour of the robot in terms of its state at any given time. For now we will define that state as having just three components:

  1. The line number in the program that the robot has just executed.
  2. A set of known variable names and their values.
  3. The output from the robot so far in its execution.

We will disregard (3) for now because the trivial program below doesn't generate output (that is, when the robot follows the instructions in the program it is executing, it doesn't print anything).

Representing the state sequence

Consider what happens as the Python Robot steps through the following program line-by-line.

wow = 20
which = wow + 5
wow = wow + which
thing = 2 * wow
The state changes at each step, and we can represent the sequence of states in a state sequence table as shown below.

State sequence table example

Note the following:

  • At each given step, we can read across the row to see the state of the program. For example, at step 3:
    • We are at line number 3.
    • The variable wow has the value 45. The smooth shading indicates it was assigned that value at this step.
    • The variable which has the value 25. The striped shading indicates it was assigned that value at some earlier step.
    • The variable thing is still undefined - it doesn't actually exist yet.
  • In a state sequence table, the order of the columns of variables is defined to be the order in which the variables get created as the program executes.
  • You can easily see the effects of all the assignment statements by looking at all the smoothly-shaded cells.
  • Although line numbers correspond one-to-one with step numbers in this program, that will not be the case in later programs, when constructs like if statements and loops jump forwards and backwards in the code.

Please make sure you understand the state sequence table representation before continuing.

From now on, we'll drop the term "robot" and follow the more conventional terminology of talking about the "state of the program as it executes". But always keep in mind that the program is just a set of instructions and the "state as it executes" is really the state of the engine/robot that is executing the program.

<END OF STUDENT INTRO PANEL>

Some sample SST questions

The following questions are a small sample from those we've asked in our COSC131 course. Keep in mind that there were lots of other questions, tutorials and info panels between these questions, which were introduced over a three week period.

Firstly, here are the xml exports of the questions:

And now the questions. You'll need to be logged in as trial, with password trial to use them. If you login using the panel within the embedded question rather than the usual login at the top right, you'll have to refresh the page after logging in.







Last modified: Monday, 2 October 2023, 10:20 AM