AQA GCSE CSPaper 1 · Unit 2Lesson 1

Paper 1 · Unit 2 · CS-L2-01

Data Types

60 minutes · AQA 8525 · Paper 1 — Programming

Spec & Goals 3 min

AQA Spec 3.2.1 · Data types

By the end of this lesson you can:

  1. Name the five GCSE data types and give an example value for each.
  2. State the most appropriate data type for a given value.
  3. Use casting to convert a value from one data type to another.

Warm-Up 5 min

Programs store data. Each piece of data has a type — what kind of value it is.

Quick starter

For each value, say in plain English what kind of value it is:

  • 17
  • 3.5
  • True
  • 'Aisyah'
Reveal sensible answers

A whole number, a number with a decimal, a true/false value, and some text. By the end of this lesson you will give each its exact data type.

Key Concept — the five data types 14 min

A data type tells the computer what kind of value is stored. The GCSE exam uses five types.

Data typeStoresExample
IntegerWhole numbers17, −4, 0
Real (float)Numbers with decimals3.5, 0.06
BooleanOne of two valuesTrue, False
CharacterA single symbol'A', '?'
StringText (zero or more characters)'Kuala Lumpur'

Why the type matters

  • Memory used — a Boolean needs far less space than a long string.
  • Which operations are allowed — you can add two integers, but not two Booleans.
  • It prevents errors — a phone number kept as a string keeps any leading zero.

Casting — changing the type

Casting converts a value from one data type to another. A number typed by the user often arrives as a string, so you cast it before doing arithmetic.

AQA pseudo-codePythonWhat it does
STRING_TO_INT(s)int(s)String → integer
STRING_TO_REAL(s)float(s)String → real
INT_TO_STRING(n)str(n)Integer → string

Worked Example — read a price and add tax 12 min

Problem: read a price typed by the user, then output the price plus RM2 delivery.

The input arrives as a string, so we cast it to a real before the arithmetic.

AQA pseudo-code

priceText ← USERINPUT
price ← STRING_TO_REAL(priceText)
total ← price + 2.00
OUTPUT 'Total: RM' + INT_TO_STRING(total)

The same algorithm in Python

price_text = input("Enter the price: ")
price = float(price_text)
total = price + 2.00
print("Total: RM" + str(total))

If the user enters 10.50, the output is Total: RM12.5.

Try It Yourself 12 min

🟢 Easy

Goal: State the most appropriate data type for each value: 42, 9.99, 'Z', False, 'Melaka'.

Hint: match each value to one of the five types in the table above.

🟡 Medium

Goal: Write AQA pseudo-code that reads a number as a string, casts it to an integer, then outputs the number doubled.

Hint: use STRING_TO_INT, then multiply by 2 with *.

🔴 Stretch

Goal: Explain why a mobile phone number should be stored as a string, not an integer.

📝 Exam Practice 10 min

Answer the way the examiner expects — the command word and the marks tell you how much to write.

State[1 mark]

State the most appropriate data type for the value 3.14.

Mark scheme
  • Real / float (1).
State[1 mark]

State the most appropriate data type for whether a light is switched on.

Mark scheme
  • Boolean (1).
Explain[2 marks]

A program stores a person's age. Explain why an integer is used rather than a real.

Mark scheme
  • An age is a whole number, so an integer is the correct fit (1).
  • An integer uses less memory / a real would store an unnecessary decimal part (1).
Identify[1 mark]

Which one converts a string to a whole number?

A INT_TO_STRING   B STRING_TO_INT   C STRING_TO_REAL   D OUTPUT

Mark scheme
  • B — STRING_TO_INT (1).

Recap & Key Terms 3 min

The five GCSE data types are integer, real, Boolean, character and string. The type sets the memory used and the allowed operations. Casting converts one type to another, such as a string to a number.

Integer
A whole number, with no decimal part, e.g. 17.
Real
A number with a decimal part, e.g. 3.5 (also called a float).
Boolean
A value that is either True or False.
Character
A single symbol, e.g. 'A'.
String
A sequence of characters (text), e.g. 'Kuala Lumpur'.
Casting
Converting a value from one data type to another.

Homework 1 min

Task (≤ 15 min): Write, in AQA pseudo-code, a program that reads two prices as input, casts them to reals, and outputs their total.

Model answer
a ← STRING_TO_REAL(USERINPUT)
b ← STRING_TO_REAL(USERINPUT)
total ← a + b
OUTPUT total

Award marks for: two inputs cast to reals (1), a correct addition (1), output the result (1).