Prerequisite Diagnostic
Allow 30–45 minutes; first answer without the feedback.
- What happens to a when
a=[1]; b=a; b.append(2)runs? What changes if b is a copy? - Trace an object starting at 3 whose add(x) adds x, followed by add(2), then a read.
- A function appends to a list and then raises. Does catching the exception undo the append?
- What does a second loop observe after a generator is fully consumed?
- Explain the difference between a test passing on one input and a universal contract.
Feedback and repair
- a becomes [1,2]; copying the outer list prevents that structural alias.
- The observed value is 5; distinguish separate instances from shared references.
- No. Exceptions transfer control; they do not automatically roll back mutation.
- No remaining elements. A list is reusable; an exhausted iterator is not.
- The test is bounded evidence. General reasoning needs explicit assumptions.
Repair tracing/functions in Semester 0, contracts/proof discipline in Semester 1, and iterator or stateful testing gaps through a small hand trace. Do not require pre-existing SOLID expertise or advanced inheritance knowledge to enter this module.