Skip to content

Course home

Structured programming and subroutines (procedures and functions)

Structured programming and subroutines (procedures and functions)

EasyMediumHard
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
Question 27

An environmental monitoring grid measures river contamination levels across several parallel sensor lines, each having multiple detection nodes. A researcher wants to write a script to monitor the first sensor line (index 0) to detect a localized contamination spike.

Write a Python program to:

  • Check that along the first sensor line (index 0):
    • the contamination level at node 1 is strictly greater than the contamination level at node 0
    • the contamination level at node 2 is strictly greater than the contamination level at node 1
  • Display Spike when both conditions are met (indicating a continuous, strict increase).
  • Display Stable when the conditions are not met.

You must use the getContamination subroutine described below in your Python code.

Subroutine

SubroutinePurpose
getContamination(line, node)Returns the contamination level (as an integer) detected at (line, node)

Figure 1: Example A (Spike detected)

node 0node 1node 2
line 0121825
line 110119

For Example A, the program should display Spike (since 12 < 18 < 25).

Figure 2: Example B (Stable status)

node 0node 1node 2
line 0151420
line 181211

For Example B, the program should display Stable (since 14 is not greater than 15).

[4]
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