Exam Reference Language Guide - OCR GCSE Computers
OCR GCSE Computer Science exam reference language gives students a consistent way to read and write algorithms in the exam.
Examination questions use OCR Exam Reference Language for clarity and consistency. Students may also answer some questions with a high-level programming language when the question allows it.
Use this page with the practical programming skills, assessment requirements, command words, and OCR GCSE Computer Science past papers.
Operators
OCR uses operators consistently in examination questions. Students should know what each symbol or word means before tracing code.
Comparison operators
==means equal to.!=means not equal to.<and<=mean less than and less than or equal to.>and>=mean greater than and greater than or equal to.
Arithmetic operators
+,-,*, and/are used for addition, subtraction, multiplication, and division.MODgives the remainder after division.DIVgives the whole-number quotient.^is used for an exponent.
Boolean operators
ANDis true only when both conditions are true.ORis true when at least one condition is true.NOTreverses the result of a condition.
Core Constructs & Casting
Core constructs help students read and write short programs. Answers should use simple, consistent syntax and clear variable names.
Variables and constants
- Use
=to assign a value, such asx = 3. - Use
constfor a value that should not change. - Use
globalonly when a variable must be available throughout the program. - Use
//to add a comment that explains part of the code.
Input, output and casting
- Use
input(...)to get a value from the user. - Use
print(...)to display text, values, or array items. - Use
str(),int(),float(),real(), orbool()to cast data. - Check the data type before comparing or calculating values.
Control Structures Selection & Iteration
Selection and iteration control the path through a program. Students should trace each condition and check when each loop stops.
Selection
- Use
if ... then,elseif,else, andendiffor decisions. - Use
switch,case,default, andendswitchwhen one value has several possible outcomes. - Each condition should be clear and test one decision point.
- Trace selection by checking which branch runs.
Iteration
- Use
for ... to ... nextfor count-controlled loops. - Use
stepwhen the counter changes by more than one or counts down. - Use
while ... endwhilewhen the condition is checked before the loop runs. - Use
do ... untilwhen the loop must run at least once. - Check start values, stop values, and changes to the loop variable.
String Handling & Operations
String handling questions test how programs process text. Students should remember that string positions are zero indexed in the OCR reference language.
Common string tools
- Use
.lengthto find the number of characters. - Use
.substring(x, i),.left(i), and.right(i)to take part of a string. - Use
+to join strings together. - Use
.upperand.lowerto change case. - Use
ASC(...)andCHR(...)to convert between characters and ASCII values.
File Handling & Arrays
File handling and arrays appear in questions where a program stores, reads, or processes data. Students should pay close attention to indexes and file operations.
File handling
- Use
open(...)to open a file and store it as a variable. - Use
.readLine()to read the next line. - Use
.writeLine(...)to add a line to the end of a file. - Use
.endOfFile()to check whether all lines have been read. - Use
.close()when the program has finished using the file. - Use
newFile()to create a new file.
Arrays
- Use
array colours[5]to create a one-dimensional array with five elements. - Array indexes start at 0, so five elements use indexes 0 to 4.
- Arrays store values of a single data type.
- Use a two-dimensional array, such as
array grid[8,8], for rows and columns. - Assign values by using the index, such as
names[3] = "Noni".
Sub programs & Random Numbers
Subprograms break a solution into smaller parts. Random numbers are useful when a program needs a value chosen within a given range.
Procedures and functions
- Use
procedure name(...)andendprocedurefor a subprogram that does not return a value. - Call a procedure by writing its name and any parameters.
- Use
function name(...),return, andendfunctionfor a subprogram that returns a value. - Store a returned value in a variable if the program needs it later.
Random numbers
- Use
random(1, 6)to generate an integer from 1 to 6 inclusive. - Use real-number limits when the program needs a random decimal value.
- Check whether the question expects an integer or a real number.
Using the reference language
Students should learn the exam reference language by writing short programs and tracing each line. The aim is to understand the logic, not just memorise the syntax.
Good practice includes variables, constants, input, output, casting, selection, iteration, arrays, file handling, procedures, functions, and random numbers.
Revision checks
- Trace code before predicting output.
- Check loop start and end values.
- Use clear variable names in written answers.
- Check array indexes carefully.
- Practise converting between pseudocode, flowcharts, and program code.