Skip to content

Course home

Programming fundamentals

Programming fundamentals

EasyMediumHard
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
Question 4

An automated greenhouse irrigation system controls watering zones. Each zone has a specific code, as shown in the table below:

CodeZone Type
NTNorth Tunnel
STSouth Tunnel
HPHydroponics

A program is written to update irrigation settings. The program:

  • displays an initialising message
  • asks the user to enter the zone code
  • calls the prewritten function CheckZoneValid() to check whether the entered code is valid
  • if valid, asks the user to input the target soil moisture percentage, combines them to form a control command, and calls a procedure QueueCommand()
01  print("Irrigation System Controller v2.1")
02  zoneCode = input("Enter zone code: ")
03  isValid = CheckZoneValid(zoneCode)
04  if (isValid == true) then
05      targetMoisture = input("Enter target soil moisture percentage: ")
06      controlCommand = zoneCode + ":" + targetMoisture
07      QueueCommand(controlCommand)
08  endif

Give the line number that contains the call to the prewritten validation function.

[1]
Markscheme

Programming fundamentals Questions

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

95 exam-style questions on OCR GCSE Computer Science Programming fundamentals. Each one has a worked solution and a mark scheme showing where the marks go.

Question bank