Skip to content

Coding fundamentals

Coding fundamentals every GCSE student needs

The handful of ideas behind every program ever written, explained clearly with short Python examples.

A learner writing code on a laptop

What coding really is

Coding is writing precise instructions for a computer. Every program, from a calculator to a video game, is built from the same small set of ideas. Learn these well and any language becomes easier.

Variables and data types

A variable is a named store for a value that can change. Every value has a data type.

Data typeHoldsExample
IntegerWhole numbersage = 15
Real (float)Decimal numbersprice = 2.99
StringTextname = "Sam"
BooleanTrue or Falsepassed = True
CharacterA single charactergrade = "A"

A constant is a value that does not change while the program runs, such as VAT_RATE.

Sequence

Instructions run in order, top to bottom. Changing the order changes the result.

Selection

if score >= 50:
    print("Pass")
elif score >= 40:
    print("Nearly there")
else:
    print("Try again")

Iteration

Count-controlled loops run a set number of times. Condition-controlled loops run until something changes.

for i in range(5):
    print("Hello")

password = ""
while password != "letmein":
    password = input("Password: ")

Operators

+ - * /Add, subtract, multiply, divide
// (DIV)Whole number division: 17 // 5 = 3
% (MOD)Remainder: 17 % 5 = 2
**Power: 2 ** 3 = 8
== != < > <= >=Comparisons
and or notBoolean operators

Functions and procedures

A subroutine is a named block of code you can reuse. A function returns a value; a procedure does not.

def area(width, height):
    return width * height

print(area(4, 5))

Local variables exist only inside a subroutine. Global variables can be used anywhere, but make programs harder to debug.

Lists and arrays

scores = [12, 18, 9]
print(scores[0])      # 12, positions start at 0
scores.append(15)
print(len(scores))    # 4

Decomposition and abstraction

Decomposition breaks a big problem into smaller ones. Abstraction removes detail that does not matter. A map of the London Underground is a famous abstraction: it ignores real distances so you can see the connections.

Writing robust programs

  • Validation: check input is sensible, such as an age between 0 and 120.
  • Testing: use normal, boundary and erroneous data.
  • Maintainability: meaningful names, comments and indentation.

Questions

Common questions

Which language should GCSE students learn?

Python is the most common in UK schools. AQA and OCR also accept others, but Python is a strong choice.

What is the difference between a function and a procedure?

A function returns a value to the code that called it. A procedure carries out a task but does not return a value.

How can my child practise?

Want help with this one to one?

Dee replies personally to every enquiry, usually within two working days.

Send an enquiry