GCSE · Computer Science · AQA · Spec 8525

Concept of a data type

Type 5, then 3, into a program that adds them, and it proudly answers 53. It isn't broken — it's doing exactly what the data types tell it to.

Computer Science · Data types

Why did 5 + 3 give 53?

A short Python program asks the user for two numbers and adds them. Step through it one line at a time and keep an eye on the quotation marks in the Variables panel.

The user types 5, then 3. Before you step onto line 3, predict: what will print(first + second) show?

1 first = input("First number: ")
2 second = input("Second number: ")
3 print(first + second)
4 first = int(first)
5 second = int(second)
6 print(first + second)

Variables

first="5" (string)

Output

First number: 5

Step 1: The user types 5. But input() always hands back text, so first holds the string "5" — the character 5, not the number 5. Spot the quotation marks.

1 / 6

Press Next one line at a time. The moment to watch is line 3 — then compare it with line 6.

Step 1 of 6: The user types 5. But input() always hands back text, so first holds the string "5" — the character 5, not the number 5. Spot the quotation marks..

Exam line: A value's data type, not the symbol you write, decides what an operation does to it.
Watch out: Digits typed at the keyboard arrive as a string. Cast them to a number before you do any arithmetic with them.

Computer Science · Data types

Sort the values by data type

Which data type is each value? Pick a value, then pick its type.

Still to sort

Integer (0)

A whole number — positive, negative or zero.

Where the line is: No fractional part. As soon as a number is written with a decimal point, even 5.0, it is a real.

Real (float) (0)

A number with a fractional part. Also called floating point, or a float.

Where the line is: It is how the number is written that counts: 5.0 is a real even though its value is whole.

Boolean (0)

Only ever one of two values: True or False.

Where the line is: True with no quotation marks is a Boolean. Put it in quotation marks and it becomes a string of four letters.

Character (0)

A single letter, digit or symbol.

Where the line is: Exactly one symbol. Two or more characters together make a string. (Some languages, such as Python, have no separate character type and simply use a string of length one.)

String (0)

A sequence of characters, written inside quotation marks.

Where the line is: Anything inside quotation marks is text — even if every character in it is a digit.

8 of 8 still to sort.

Five data types come up again and again. Commit to an answer for each value before you read the reason.

Watch out: Two of these values are made of the same digits but belong to different types. The quotation marks are what decide it.

Computer Science · Casting

Now cast the other way: number to string

A game keeps the player's score as an integer, adds a bonus, then shows the score in a message. The program is in Python. Supply the missing line so the message works.

  1. score = 17score is an integer, because the game still needs to do arithmetic with it.
  2. bonus = 3
  3. score = score + bonusBoth are integers, so + adds: score is now 20.
  4. missing step
Which line is step 4?

Exam line: To join a number into a message, cast the number to a string with str() before joining it.

Computer Science · Choosing a data type

What do you really think?

A sign-up form asks for your age. You type 15, and the program stores exactly what you typed.

Which of these is closest to what you think right now?
How sure are you?

Exam line: Pick the data type that fits what the data is and what the program will do with it.

WHAT YOU'VE LEARNED

A quick recap of today's lesson.

Why "5" and 5 are not the same thing, and how to convert between them.

What you need to know

  • A data type is the kind of value a piece of data is. It decides which values the data can take, how it is stored and which operations work on it.
  • Integer: a whole number, such as 42, -7 or 0.
  • Real (also called floating point, or float): a number with a fractional part, such as 3.75 or 5.0.
  • Boolean: only two possible values, True or False.
  • Character: a single letter, digit or symbol, such as 'A'. String: a sequence of characters, such as "hello" or "42".
  • Casting converts a value from one data type to another: int("5") gives the integer 5, and str(20) gives the string "20".

The big picture

Every value in a program has a data type: integer, real, Boolean, character or string. The type decides which values the data can take, how it is stored and which operations work on it — so the same + adds two integers but joins two strings. Casting converts a value from one type to another, and choosing the right type in the first place avoids errors and wrong answers.

Key points

1Digits in quotation marks are a string, not a number: "42" is two characters.
2The same operator can behave differently by type: + adds integers but joins (concatenates) strings.
3Keyboard input usually arrives as a string, so cast it before doing arithmetic with it.
4Choose the type that fits the data. The wrong type causes errors or wrong results.

Worked example

Problem

A leisure centre's membership program needs to store six things about each member: their name, their age in years, their height in metres, whether they have paid this month, their membership grade (a single letter, A to C) and their phone number. Choose the most suitable data type for each, with a reason.

⚠ Watch out

Treating digits as a number just because they look like one. "42" in quotation marks is a string: until you cast it with int(), + will join it rather than add it, and in Python, mixing it with an integer causes an error.

🧠

Memory hook

Quotation marks are a disguise: "42" looks like a number, but it's text in a costume. Casting takes the costume off.

✓

Check yourself

Cover the page. Name the five data types with an example of each. Then say why "7" + "7" doesn't give 14, and what would fix it.

Flashcards

(11)
What is a data type?
The kind of value a piece of data is. It decides which values the data can take, how it is stored and which operations work on it.
Integer
A whole number — positive, negative or zero. E.g. 42, -7, 0.
Real (float)
A number with a fractional part. E.g. 3.75, or 5.0 (a real because it is written with a decimal point).
Boolean
A data type with only two possible values: True or False.
Character
A single letter, digit or symbol, e.g. 'A', '7' or '?'.
String
A sequence of characters in quotation marks, e.g. "hello" or "42".
Is "42" a number?
No. The quotation marks make it a string of two characters. It can't be used in arithmetic until it is cast to an integer.
What is casting?
Converting a value from one data type to another, e.g. int("42") gives 42 and str(42) gives "42".
What is concatenation?
Joining strings end to end with +, e.g. "sun" + "set" gives "sunset".
What type does keyboard input usually arrive as?
A string — even when the user types only digits. Cast it before doing arithmetic.
What can go wrong if you choose the wrong data type?
Errors (e.g. Python won't + a string and an integer) or wrong results (e.g. as strings, "10" sorts before "9").

Tap any card to flip it, or use Study as deck to go through them one at a time. In the full lesson these run as a spaced-repetition deck — you rate each card Hard, Good or Easy and the tricky ones keep coming back until they stick.

Learning with Lightbulb is opening soon

You can use this lesson now. Join the waitlist and we'll let you know when the full Lightbulb experience is ready.

Keep me posted

More AQA GCSE Computer Science topics

See the full AQA Computer Science curriculum →

How this lesson was checked. This AQA GCSE Computer Science (specification 8525)lesson was published through Lightbulb Learning's human-designed editorial process — the educational standards, accuracy rules and publication checks it must pass were authored and approved by Philip Halpin. It passed subject-specific assessment, automated educational checks and technical publication verification before going live (publication checks completed 29 September 2026). Published pages are monitored, human spot-checking is ongoing across the lesson library, and anything found wrong is corrected or withdrawn. How our lessons are made and checked. Spotted a mistake? Email hello@lightbulblearning.co and we'll review it.