Skip to content

Course home

Programming fundamentals

Programming fundamentals

EasyMediumHard
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
Question 64

An automated library checkout machine allows library items to be scanned and processed. Each type of library item has a two-letter prefix code. The prefixes are defined in the table below:

CodeItem Type
BKBook
DGDigital Media
MGMagazine

A program is written to process these items at checkout. The program:

  • Asks the librarian to enter the code for the type of item being checked out.
  • Calls a prewritten function CheckItemCode() to verify whether the entered prefix code is valid.
  • If the code is valid, the user is prompted to input the unique item number, which is concatenated with the prefix to form a unique SKU, and the function CheckoutItem() is called.
01  itemType = input("Enter the code for the item type:")
02  if CheckItemCode(itemType) then
03      itemNumber = input("Enter the unique item number:")
04      itemSKU = itemType + itemNumber
05      CheckoutItem(itemSKU)
06  endif

Identify two programming constructs that have been used in the program above.

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