Skip to content

Course home

Programming fundamentals

Programming fundamentals

EasyMediumHard
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
Question 44

A laboratory inventory system tracks hazardous chemical containers. Each container material has a specific code, as shown below:

CodeMaterial
GLGlass
PLPlastic
MTMetal

A program is written to log new batches into the inventory database. The program:

  • prompts the operator to input the container material code
  • prompts the operator to input the unique batch number
  • calls the prewritten function IsValidContainer() to check whether the entered material code is valid
  • if valid, combines the material code and batch number with a hyphen, and calls the procedure RegisterBatch() to update the database
01  containerCode = input("Enter container material code: ")
02  batchNum = input("Enter batch number: ")
03  if (IsValidContainer(containerCode)) then
04      trackingRef = containerCode + "-" + batchNum
05      RegisterBatch(trackingRef)
06  else
07      print("Error: Invalid container code.")
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