What are programming fundamentals?
This is the core toolkit every programmer needs: variables, constants, sequence, selection, iteration, operators and data types. OCR J277 expects you to read, trace and write pseudocode or code (Python-style) using these building blocks.
Data types
- Integer: whole numbers, e.g. 7 or -3.
- Real (float): numbers with a decimal point, e.g. 3.14.
- Boolean: only True or False.
- Character: a single letter, digit or symbol.
- String: a sequence of characters, e.g. 'hello'.
- Casting converts one type to another, e.g. int('5') turns the string '5' into the integer 5. Common mistake: forgetting that input() in Python always returns a string, so numbers typed in must be cast before doing maths on them.
Variables and constants
A variable stores a value that can change while the program runs; a constant stores a value that stays fixed. Use meaningful identifier names. Assignment uses = (e.g. score = 0), while == tests equality in a condition. Mixing these up is one of the most common exam and coding errors.
The three constructs
- Sequence: instructions run in order, top to bottom.
- Selection: IF, ELSE IF (ELIF), ELSE branch the logic based on a condition; nested IFs place one selection inside another.
- Iteration: count-controlled loops (FOR) repeat a set number of times; condition-controlled loops (WHILE, or REPEAT...UNTIL) repeat until a condition is met. A WHILE loop checks the condition BEFORE running the body, so it might run zero times; REPEAT...UNTIL checks AFTER, so it always runs at least once.
Operators
- Arithmetic: + - * / (division), // (integer/floor division, drops remainder), MOD or % (remainder), ^ or ** (exponent/power).
- Relational (comparison): > < >= <= == != — these always produce a Boolean result.
- Boolean/logical: AND, OR, NOT combine or invert conditions, e.g. IF age >= 18 AND hasID == True.
String handling and arrays
Know string operations: length (LEN), concatenation (+), substring/slicing, converting case, and finding a character's position. Arrays (or lists) store multiple values under one identifier, indexed from 0 in most exam pseudocode and in Python — a classic off-by-one mistake is thinking the first item is index 1.
Nested and combined structures
Expect exam questions that nest loops inside selections, or selections inside loops, then ask you to trace the output by hand — write out variable values step by step in a trace table rather than guessing.
What is the difference between = and == in code?
= is assignment (stores a value in a variable); == is a comparison operator that tests if two values are equal.
tap to reveal
Why must you cast the result of input() before doing maths with it?
input() always returns a string, so it must be cast with int() or float() before it can be used in arithmetic.
tap to reveal
What index does the first element of an array have?
0 — arrays and lists are zero-indexed.
tap to reveal
What does the // operator do?
Integer (floor) division — divides and discards the remainder, e.g. 7 // 2 = 3.
tap to reveal
What does MOD (or %) return?
The remainder after division, e.g. 7 MOD 2 = 1.
tap to reveal
When does a WHILE loop check its condition?
Before running the loop body, so the body may run zero times.
tap to reveal
When does a REPEAT...UNTIL loop check its condition?
After running the loop body, so the body always runs at least once.
tap to reveal
What type of loop is a FOR loop?
Count-controlled — it repeats a known, fixed number of times.
tap to reveal
Name the four core data types tested in OCR Programming Fundamentals.
Integer, real (float), Boolean, and character/string.
tap to reveal
What do the Boolean operators AND, OR and NOT do?
They combine or invert conditions and always produce a True or False result.
tap to reveal
What is casting?
Converting a value from one data type to another, e.g. int('5') to 5, or str(5) to '5'.
tap to reveal
What is the difference between a variable and a constant?
A variable's stored value can change while the program runs; a constant's value stays fixed.
tap to reveal
What are the three basic programming constructs?
Sequence (instructions in order), selection (IF/ELIF/ELSE branching), and iteration (loops).
tap to reveal
What does nested selection mean?
Placing one IF statement entirely inside the body of another IF statement.
tap to reveal
Why is a trace table useful for loop and selection questions?
It records each variable's value step by step as the code runs, avoiding guesswork when working out the output.
tap to reveal