Skip to content

Course home

Structured programming and subroutines (procedures and functions)

Structured programming and subroutines (procedures and functions)

EasyMediumHard
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
Question 16

A Python program operates on a 3x3 automated warehouse storage grid containing cargo containers numbered from 1 to 8, with one empty bay represented by 0.

The subroutines available for controlling the automated system are described in the table below:

SubroutinePurpose
inspectBay(row, column)Returns the ID of the cargo container in the storage grid in position (row, column). The value 0 represents an empty bay.
shiftItem(row, column)Shifts the container at (row, column) into the adjacent empty bay, if the empty bay is directly next to it (horizontally or vertically).

Initial Storage Grid State

Column 0Column 1Column 2
Row 0472
Row 1105
Row 2836

Program of Instructions

if inspectBay(1, 1) == 0:
    shiftItem(2, 1)

if inspectBay(2, 1) == 0:
    shiftItem(2, 2)

Complete the table below to show the final state of the storage grid after the program has run.

Column 0Column 1Column 2
Row 0
Row 1
Row 2
[2]
Markscheme

Structured programming and subroutines (procedures and functions) Questions

  1. GCSE
  2. /Computer Science
  3. /Structured programming and subroutines (procedures and functions)

131 exam-style questions on AQA GCSE Computer Science Structured programming and subroutines (procedures and functions). Each one has a worked solution and a mark scheme showing where the marks go.

Question bank