Python Computer — 1. Beginning

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 beginning stage, it only covers control flow and variables (without references) of Python scripts.

Mapping

PLNM
memory table of identifer and value
instruction update of state according to defined rules
variable entry in the table
conditional conditional evaluator (flag) that affects the 'program counter'
control flow program counter that identifies next line to get executed and is updated according to a set of rules

Draws Attention To

Semantics of control flow in Python. Visible effects of each line on the 'state' of the Python computer.

Use When

At the beginning of a typical 'walk through' of the different programming constructs.

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