7Easy
0/3

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 0Bay 1Bay 2Bay 3Bay 4Bay 5Bay 6Bay 7
Level 0SafeSafeSafeSafeSafeSafeSafeSafe
Level 1SafeSafeSafeSafeSafeSafeSafeSafe
Level 2SafeSafeSafeSafeSafeSafeSafeSafe
Level 3SafeSafeSafeHazardousSafeSafeSafeSafe
Level 4SafeSafeSafeSafeSafeSafeSafeSafe

Explain the purpose of the first iteration structure (the outer loop) in the program in Figure 1.

[3]

Programming concepts Questions

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.

PreviousNext

Programming concepts Questions

  1. GCSE
  2. /Computer Science
  3. /Programming concepts