An automated warehouse retrieval program is designed to locate hazardous materials in a storage racking system. The racking is organized into 5 levels and 8 bays per level.
Figure 1 shows a section of the program used to identify the coordinates of a "Hazardous" storage bay.
Figure 1
hazard_level = -1
hazard_bay = -1
for level in range(0, 5):
for bay in range(0, 8):
if get_bay_contents(level, bay) == "Hazardous":
hazard_level = level
hazard_bay = bay
Figure 2 shows an example layout of the storage bays.
Figure 2
| Bay 0 | Bay 1 | Bay 2 | Bay 3 | Bay 4 | Bay 5 | Bay 6 | Bay 7 | |
|---|---|---|---|---|---|---|---|---|
| Level 0 | Safe | Safe | Safe | Safe | Safe | Safe | Safe | Safe |
| Level 1 | Safe | Safe | Safe | Safe | Safe | Safe | Safe | Safe |
| Level 2 | Safe | Safe | Safe | Safe | Safe | Safe | Safe | Safe |
| Level 3 | Safe | Safe | Safe | Hazardous | Safe | Safe | Safe | Safe |
| Level 4 | Safe | Safe | Safe | Safe | Safe | Safe | Safe | Safe |
Explain the purpose of the first iteration structure (the outer loop) 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.