The aim is to predict a result before pressing Run. A final number alone cannot show whether you followed the changing state or guessed correctly. You will trace a tiny warehouse calculation in which two names first hold the same integer and two other names later share one list. No warehouse system or actual inventory is involved.
Documentation boundary
Python’s execution-model reference describes names as referring to objects and assignment as a binding operation. This workshop uses the Python 3.12 documentation edition. Its example and answers were checked locally with Python 3.12; it makes no claim about the latest interpreter release.
Prepare the trace before running
Use six columns on paper: completed statement, stock, reserved, boxes, alias, and a note about shared objects. Write a dash for a name that has not yet been assigned. Read statements from top to bottom, updating only the cells affected by that statement. When a list changes, record its complete contents rather than only the newest item. This makes the trace useful for explaining a result to another learner.
Your tasks are to predict the final printed line, identify the first statement after which stock and reserved differ, and decide whether changing alias affects boxes. Give a reason for each answer. Do not replace the programme with mental arithmetic that skips the intermediate states: the shared-list question cannot be answered from the final stock total alone.
stock = 12
reserved = stock
stock = stock - 3
boxes = [2, 4]
alias = boxes
alias.append(stock)
reserved = reserved + boxes[0]
assert (stock, reserved, boxes, alias) == (9, 14, [2, 4, 9], [2, 4, 9])
assert boxes is alias
print(stock, reserved, boxes)
Worked state table
| Completed action | stock | reserved | boxes and alias |
|---|---|---|---|
| Initial two assignments | 12 | 12 | Not assigned |
| Subtract three | 9 | 12 | Not assigned |
| Create list and alias | 9 | 12 | Both refer to [2, 4] |
| Append stock | 9 | 12 | Both refer to [2, 4, 9] |
| Update reserved | 9 | 14 | Both refer to [2, 4, 9] |
The answer is 9, 14 and the list [2, 4, 9]. The subtraction is the first point where the integer values differ: stock becomes nine while reserved remains twelve. At the append step the current stock value, nine, is added. Finally boxes[0] is two, so the update to reserved computes twelve plus two. The shared list is not used as a running total.
Draw two boxes for the names boxes and alias, with arrows to one list. Draw stock and reserved separately. The picture is a record of this exercise, not a claim that a particular memory address or storage layout must appear on every interpreter. Explain the difference between a name and the value shown in its current table cell using your own words.
Diagnose two tempting wrong answers
A reserved value of eleven usually means that you silently treated reserved as a permanent formula based on stock. Locate the exact statement where that assumption entered your trace. A boxes value of [2, 4] usually means that you treated alias as a second independent list. Neither answer can be repaired by changing only the final printed line; revise the first incorrect table row and then recompute the rows below it.
Now replace alias = boxes with alias = boxes.copy() and predict the result without running it. The revised exercise ends with boxes [2, 4], alias [2, 4, 9], stock nine and reserved fourteen. Check that prediction in a separate local scratch copy. Preserve the original answer so the two cases remain comparable. This is a useful controlled variation because you change one statement while keeping the input values fixed.
Submit evidence of understanding
A complete submission contains the trace table, the final output, the shared-object sketch, and a short explanation of the changed-copy case. Award yourself one point for each correct intermediate state and one for locating the first wrong row in a mistaken trace. If you only have the right final output, repeat the task with stock starting at fifteen and explain why the appended item changes while the first list item does not.
For a partner check, exchange predictions before revealing either output. Ask the partner to choose one row and justify every cell that changed. Accept a correction only when it identifies a statement and its immediate effect. This prevents an exercise about tracing from becoming a contest in remembering a final answer.
Questions for this exercise
Does assignment turn reserved into a live formula?
No. The execution-model account is about binding names; this exercise does not define a formula that automatically recalculates reserved.
What must I hand in?
The intermediate state table, the predicted output, the shared-list sketch and the separate changed-copy result.
Do I need real stock records?
No. The entire task uses the fictional numbers printed here and can be completed on paper before local execution.
Official documentation
Explore the Courses overview or use Contact for general enquiries. This is an original INTIAU editorial self-study exercise; no qualification is awarded.
Related guides
View the study diagram

