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.
Practise AQA GCSE Computer Science Programming concepts with exam-style questions for GCSE Computer Science. 100 questions, matched to the AQA GCSE Computer Science (8525) specification and written in Paper 1 and Paper 2 style. Every question includes a full worked solution and mark scheme, so you can see where marks are awarded rather than just whether you got the answer right.