Skip to content

Programming fundamentals

GCSE Computer Science revision notes, key terms and practice questions.

In short

A variable is a named location in memory that stores a value, which can change while the program runs. A constant stores a value that does not change, such as VAT = 0.2.

For GCSE students in Years 10 and 11, on the AQA, OCR, Edexcel and Eduqas Computer Science courses.

Variables and constants

  • A variable is a named location in memory that stores a value, which can change while the program runs. A constant stores a value that does not change, such as VAT = 0.2.
  • Assignment gives a variable a value. AQA pseudocode writes score ← 0; OCR's Exam Reference Language and Python write score = 0.

The three programming constructs

  • Sequence: instructions run one after another. Selection: IF … ELSE (or CASE / SWITCH) chooses a path. Iteration: loops repeat code.
  • Count-controlled (definite) iteration: a FOR loop repeats a set number of times. Condition-controlled (indefinite) iteration: WHILE and REPEAT … UNTIL loops repeat until a condition changes. (OCR writes DO … UNTIL; Python only has WHILE.)
  • A WHILE loop checks its condition at the start, so it might not run at all. A REPEAT … UNTIL loop checks at the end, so it always runs at least once.
  • Loops and IF statements can be nested inside each other.

Operators

  • Arithmetic: + − * / and also integer division (DIV) and remainder (MOD). 17 DIV 5 = 3 and 17 MOD 5 = 2. In Python these are // and %.
  • Comparison: = (== in Python), ≠ (!= in Python), <, >, ≤ (<=) and ≥ (>=). Boolean operators: AND, OR and NOT.
  • Powers: OCR writes 2 ^ 3 and Python writes 2 ** 3. Both mean 2³ = 8.

Input, output and strings

  • Programs take input from the user and display output. Input from the keyboard arrives as a string.
  • String handling includes finding the length, taking a substring, concatenation (joining strings) and changing the case. "Hello" has length 5.
  • Programs can also generate random numbers, such as a random integer from 1 to 6 for a dice.

Key terms

Variable
A named memory location that stores a value that can change.
Constant
A named value that does not change while the program runs.
Assignment
Giving a variable a value.
Count-controlled loop
A loop that repeats a set number of times, such as FOR.
Condition-controlled loop
A loop that repeats until a condition changes, such as WHILE.
DIV
Integer division: how many whole times one number goes into another.
MOD
The remainder after integer division.
Concatenation
Joining two or more strings together.

Quick questions on Programming fundamentals

What is 17 MOD 5?
2: 17 = 3 × 5 + 2, so the remainder is 2.
What is 17 DIV 5?
3: 5 goes into 17 three whole times.
What is a variable?
A named memory location whose value can change: For example, score or total.
Why is VAT_RATE a good choice for a constant?
Its value stays the same while the program runs: If the rate changes, the programmer only updates it in one place.
Which type of loop is a FOR loop?
Count-controlled: It repeats a set number of times.
Which loop always runs at least once?
REPEAT … UNTIL: It checks its condition at the end.
Which construct is used to choose between paths?
Selection: For example, IF … ELSE.
What does concatenation mean?
Joining strings together: "Hi " joined with "there" gives "Hi there".

Programming fundamentals: questions and answers

What is the length of the string "Hello"?
It has 5 characters.
What is the result of NOT (5 > 3)?
5 > 3 is True, and NOT True is False.
total starts at 0. A loop adds i to total for i = 1, 2 and 3. What is total at the end?
0 + 1 + 2 + 3 = 6.

Practise Programming fundamentals: 24 questions

Download these notes as a PDF

Previous topic: Searching and sorting algorithmsNext topic: Data types, arrays and records

More in Programming

LycoLearn is still loading…

This can take a little longer on a busy school or home network. If nothing happens, try refreshing the page.

LycoLearn didn’t load properly

Part of it didn’t arrive. Try refreshing the page in a minute, or open LycoLearn in another browser.