An automated inventory drone scans a vertical storage rack of 5×5 5 \times 5\,5×5 compartments to find compartments marked for restocking.
The Python code used to control the scanning process is shown in Figure 1, and the status of the storage rack is represented by the grid in Figure 2.
Figure 1
for level in range(5):
for bay in range(5):
if check_status(level, bay) == "Restock":
target_level = level
target_bay = bay
Figure 2
| Bay 0 | Bay 1 | Bay 2 | Bay 3 | Bay 4 | |
|---|---|---|---|---|---|
| Level 0 | Full | Full | Full | Full | Full |
| Level 1 | Full | Full | Full | Full | Full |
| Level 2 | Full | Full | Restock | Full | Full |
| Level 3 | Full | Full | Full | Full | Full |
| Level 4 | Full | Full | Full | Full | Full |
Explain the purpose of the second iteration structure (for bay in range(5):) in the program in Figure 1.
298 exam-style questions on AQA GCSE Computer Science Programming concepts. Each one has a worked solution and a mark scheme showing where the marks go.