Unit 05 · overview
Unit 5: Loops & Automation
Repetition becomes automation only when you understand what changes on each pass and why the repetition stops.
A loop that produces the right output once can still be wrong if it skips a case, repeats one twice, mutates the wrong state, or never terminates.
Watch one iteration at a time
You will work with for, range(), while, counters, accumulators, break, and the state that controls termination.
Instead of staring at a loop as one block of code, trace it as a sequence:
iteration -> current value -> condition -> body effect -> next state
That trace makes off-by-one errors visible. It also explains why range(5) does not mean “the numbers one through five,” and why a while loop needs a state change that can eventually make its condition false.
Automation test
Your Unit evidence is one useful loop plus a loop-forensics record. Include the starting state, at least three iterations, the termination condition, final state, and one controlled failure such as a missing update or wrong range endpoint.
The goal is not “use a loop.” The goal is to prove that the loop processes the intended cases and has a reason to stop.