Computing / Lesson 01

Procedures and state

Read programs as precise transformations of state, beginning with Python.

Reading time
42 minutes
Evidence
unseen
Release
0.1-preview
Review
Subject review pending

orient

Why this idea had to exist

Programming begins when an intention becomes a sequence another machine can execute without guessing. Tracing state makes that sequence inspectable and turns debugging into explanation rather than trial and error.

intuition

Build a picture you can reason with

Imagine a workbench with labeled cards. An assignment changes which value a label refers to. A function creates a temporary bench with inputs, performs a transformation, and returns a result. A loop repeats a controlled change until its rule says stop.

formalize

Give the intuition a precise edge

A program state maps names and locations to values. Assignment updates the state; expressions evaluate within it. Control flow selects the next instruction. A function defines a parameterized state transition and may return a value without exposing its local names.

work through

Follow the decisions, not just the symbols

Trace total=0 followed by a loop over [2,4,6] that adds each value. The states are 0→2→6→12. The crucial step is recording the old total and current item before applying the assignment.

experiment

Change one thing and watch the model answer

Step through a small Python trace one expression at a time. Predict the next state before revealing it, then change the input list and identify which instructions remain invariant.

retrieve

Close the page and reconstruct it

Answer before opening the explanation. Retrieval is evidence only when the answer is produced without a hint.

What information must a state trace record to explain an assignment?

It must record the relevant values before evaluation, the expression result, and the updated binding or location afterward.

transfer

Move the idea into a new setting

Write and trace a function that converts a sequence of temperatures from Celsius to Fahrenheit without mutating the input list.

reflect

Leave with a diagnostic habit

When code surprises you, slow time down. Write the state before and after the smallest instruction that changes it.

Source record

Follow the idea back.

Reference
The Python Tutorial
Publisher
Python Software Foundation
License
PSF License Version 2
Accessed
2026-08-12
URL
https://docs.python.org/3/tutorial/