Visual Programming Labs
Start here: read, predict, then trace
These labs connect a small program to its changing state. Choose a topic and programming language, predict the result, then use Next to compare each step with the highlighted code. The diagrams are guided models of the supplied examples; they do not execute arbitrary programs. Download the source to test it in a real compiler or interpreter.
Worked Python example: changing a value versus changing a list
Before using the array lab, distinguish a value copied from a position from an update to that position. This example needs only assignment, a list and zero-based indexing.
scores = [10, 20, 30]
selected = scores[1]
scores[1] = 99
print(selected)
print(scores)
Output: 20, then [10, 99, 30]. First, index 1 selects the second element and the name selected refers to the integer 20. Assigning 99 to scores[1] replaces that list entry; it does not reassign selected. This example uses immutable integers. Keeping a reference to a mutable nested object would require a different explanation.
Common mistake: expecting an ordinary assignment to create a live connection to a list position. Trace the name and the list entry separately. Index 3 would be outside this three-element list and would raise IndexError.
Try it: add selected = selected + 1 before printing. What changes?
Show the answer
The first output becomes 21. The list remains [10, 99, 30], because assigning a new integer to the name does not change the list. Save this example as list_values.py and run python3 list_values.py to check your prediction.
Language coverage: lab controls and guided explanations support ten interface languages; main-lab examples support six programming languages. The deeper OOP workshop is specifically C++17. This introductory reading is in English. Some detailed course tutorials remain English-only and show a notice. See the coverage guide.