Key Concepts and Syntax Glossary
Below are key concepts and the syntax used in OCR Exam Reference Language, based on Python. This reference language is simplified for use in exams to help focus on logic and problem-solving without needing external libraries or complex syntax.
Operators
| Type | Symbols | Description |
|---|
| Comparison | ==, !=, <, <=, >, >= | Used to compare values. |
| Arithmetic | +, -, *, /, ^, MOD, DIV | Basic mathematical operations like addition, subtraction, multiplication, division, exponentiation, modulo, and integer division. |
| Boolean | AND, OR, NOT | Logical operators are used in conditions. |
Variables and Input/Output
| Concept | Keywords/Symbols | Example |
|---|
| Assignment | = | x = 3 |
| Input | input(…) | name = input("Enter name") |
| Output | print(…) | print("Hello " + name) |
| Constants | const | const vat = 0.2 |
| Global Variables | global | global userID = "Cust001" |
Iteration (Loops)
| Type | Keywords/Symbols | Example |
|---|
| FOR loop | for … to …, next … | for i = 0 to 9
print(i)
next i |
| WHILE loop | while … endwhile | while answer != "Yes"
answer = input("New answer")
endwhile |
| DO UNTIL loop | do … until … | do
answer = input("New answer")
until answer == "Yes" |
Selection (Conditions)
| Concept | Keywords/Symbols | Example |
|---|
| IF-THEN-ELSE | if … then, elseif … then, else, endif | if x > 10 then
print("Large")
else
print("Small")
endif |
| CASE/SWITCH | switch … case …, default, endswitch | switch day:
case "Sat": print("Saturday")
case "Sun": print("Sunday")
default: print("Weekday")
endswitch |
String Handling
| Concept | Keywords/Symbols | Example |
|---|
| Length | .length | subject.length returns 15 |
| Substring | .substring(x, i) | subject.substring(3,5) returns "put" |
| Concatenation | + | print("Hello " + name) |
| Uppercase/Lowercase | .upper, .lower | subject.upper() returns "HELLO" |
Arrays
| Concept | Keywords/Symbols | Example |
|---|
| Array Declaration | array … | array colours[5] |
| 2D Array Declaration | array … […,…] | array gameboard[8,8] |
| Array Assignment | array[…]=… | gameboard[1,0] = "Pawn" |
Subprograms
| Concept | Keywords/Symbols | Example |
|---|
| Procedure | procedure name(…), endprocedure | procedure greet()
print("Hello")
endprocedure |
| Function | function name(…), return | function squared(number)
return number^2
endfunction |
File Handling
| Concept | Keywords/Symbols | Example |
|---|
| Open File | open(…) | myFile = open("file.txt") |
| Read Line | .readLine() | myFile.readLine() |
| Write Line | .writeLine(…) | myFile.writeLine("Add this line") |
| Close File | .close() | myFile.close() |