Data Types

beginner25 min

Learning objectives

  • Identify primitive data types
  • Explain the purpose of each data type
  • Select suitable data types for different scenarios
  • Declare variables using appropriate data types in Python

Learn

AQA 4.1.1.1 — Primitive data types

Retrieval: at GCSE (or in any prior programming you've done) you'll have already used values like whole numbers, decimals, text and true/false flags without necessarily naming them formally — this lesson gives that existing intuition proper vocabulary and rules.

Every value a program works with has a data type, which determines what operations are valid on it and how much memory it uses. AQA's specification lists these primitive (built-in) data types:

Data typePythonExample
Integerintage = 17
Real (float)floatprice = 4.99
Booleanboolis_valid = True
Character / Stringstrgrade = "A"
Date/Timevia datetime moduledatetime.now()

Python also has richer built-in structures — arrays (via list), records (via classes or dictionaries), and pointers/references are implicit in how Python variables work — you'll meet these formally in Fundamental Data Structures (Sequence 4).

Choosing the right type

Picking the correct data type isn't just a technicality — it changes what your program can do correctly:

# Wrong: age stored as a string
age = "17"
next_year = age + 1   # TypeError: can't add int to str

# Right: age stored as an integer
age = 17
next_year = age + 1   # 18

A common real error: reading a value from input() always gives you a string, even if the user typed a number — you must explicitly convert it:

age = int(input("Enter your age: "))

Worked example — a student profile

name = "Aisha"          # str
year_group = 13         # int
average_grade = 82.5    # float
has_bursary = False     # bool

Each variable's type was chosen to match what it represents: a name is text, a year group is a whole number, an average grade needs decimal precision, and a yes/no fact is Boolean.

Reflection

For each of these, name the most appropriate data type and explain why: a student's exam mark out of 100; whether a student has paid a trip deposit; a postcode; the number of A-level subjects a student is taking.

Practise

Apply what you've just learned in the Coding Lab.

Open Coding Lab

Test yourself

Check your understanding with exam-style questions.

Go to Exam Practice
Log in to track this lesson on your progress dashboard.
Log in