Skip to content

Course home

Programming fundamentals

Programming fundamentals

EasyMediumHard
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
Question 15

A smart garden irrigation system uses different watering devices. Each type of device has a code as shown in the table:

CodeDevice
SPSprinkler
DRDrip emitter
MSMoisture sensor

A program is written to activate these devices. The program:

  • Asks the user to enter the code of the device they want to activate.
  • Calls the prewritten function IsValidDeviceCode() to check whether the entered code is valid.
  • Reads a zone number as input if the code is valid.
  • Calls the procedure ActivateDevice() using a combined device identifier.
01  deviceType = input("Enter the device code to activate")
02  if (IsValidDeviceCode(deviceType)) then
03      zoneNumber = input("Enter the zone number for the device")
04      combinedID = deviceType + zoneNumber
05      ActivateDevice(combinedID)
06  endif

Give the identifier of a variable used in the program.

[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