Python Computer — 2. Intermediate

Python Computer is a sequence consisting of the following 4 notional machines:
1. Beginning
2. Intermediate
3. Advanced
4. Ultimate

Programming Language

imperative / Python

Form

Representation

Attribution — Origin / Source

Collected by Andreas Mühling — Own practice

Conceptual Advantage

Expandable 'offline' model of program execution. In its intermediate stage (V2) it covers everything of V1 plus definition and execution of sub-routines (functions) of Python scripts.

Mapping

PLNM
... ...
method table table of identifier and starting line
scope 'sub-table' area in the memory
parameter entry in the memory sub-table of a function call

Draws Attention To

Scoping (global vs. local variables) and sub-routines with parameters and return values.

Use When

At the beginning of a typical 'walk through' of the different programming constructs, as it can then 'grow' with each new construct.

Cost

Time consuming to prepare. Easy to follow for learners, as it grows in complexity. Can be used for exercises (fill out sheets of the computer).

Details

The idea is to offer an "offline" (in the sense of not automated) visualization of program execution. The necessary model of the computer executing the program gets increasingly more complex, as more programming constructs are introduced. Similar ways of stepping through code can be found in the typical visualization (or debugging) tools and this connection between "offline" and "online" is intentional.

In its basic form, the executor can "run" a script sequentially and jump in the script based on the evaluation of a conditional. Variables of "primitive" types (i.e. str, int, float, bool) are stored in a memory table that consists of identifier and current value. A template for all stages can be found here An example for the execution of a simple script in German can be found here ("Speicher" = "Memory", Bezeichner = Identifier, Wert = Value, Bedingung = Condition, Nächste Zeile = Next Line).

It also shows the big drawback of having it as slides only: It becomes cumbersome for more than very simple scripts to create and once finished, modifications to a program are time consuming. The advantage is that, once introduced, it is not necessary to always step through a program from the beginning, a slide can also jump right into the middle of an execution to highlight interesting phenomena. As it is manual and on slides, it is also easy to add boxes or other elements to guide students' attention to some aspect. Also, the template can be used in exercises and assessments and students can fill in various aspects of the NM (e.g. the memory after a program has been run).

Comments or Feedback?

Do you have feedback on this notional machine? Did you find a mistake, or do you have a request for improvement? You can create an Issue on GitHub, where the description is hosted. This way we can see your feedback and address it.

For this, you need a GitHub account. Then follow this link to see the source file of this page. In there, click the ... left of the highlighted line, then pick "Reference in a new issue".

Create an Issue on GitHub