GCSE · Computer Science · AQA · Spec 8525
Real (float) data type
Four quiz scores, all whole numbers: 6, 9, 8 and 7. Their average? 7.5. So where does that .5 live — and what happens if the program gave it nowhere to go?
Computer Science · Choosing a type
Whole numbers in, a fraction out
Four quiz scores go in. Step through the program one line at a time and watch the trace table fill up.
Predict before step 3: every score is a whole number. Will average be a whole number too?
1 total ← 6 + 9 + 8 + 72 count ← 43 average ← total / count4 OUTPUT average
| total | count | average |
|---|---|---|
| 30 |
Output
Step 1: Four whole numbers add up to a whole number: 30. An integer is fine for total.
Use Next to step one line at a time. Every value is worked out for you — check each one in your head before you trust it.
AQA exams use the general names integer, real, Boolean, character and string. So in the exam, write real — not float — even if you program in Python.
WHAT YOU'VE LEARNED
A quick recap of today's lesson.
A data type decides which values a variable can hold. Real holds numbers that can have a fractional part, like 3.75 — and whole numbers too.
What you need to know
- A data type sets which values a variable is allowed to hold. Common ones are integer, real, string and Boolean.
- Real holds numbers that can have a fractional part, such as 3.75 or −0.5.
- Real holds whole numbers too — 12 sits happily in a real variable.
Have a goYour friend stores 12 in a real variable and announces: 'That's broken — 12 hasn't even got a decimal point!' Are they right?
No. A real can hold 12 perfectly well.
Real means the value CAN have a fractional part, not that it must. Your friend has mixed up 'has room for' with 'has to have'.
- Integer is stricter: whole numbers only, so 12.5 can't go in an integer.
- Size and sign never decide it. 250000 and −12 are both whole, so integer can hold them.
Have a goThree values: −40, 0.25 and 1000000. Which of them would an integer variable refuse?
Only 0.25.
−40 is negative and 1000000 is huge, but both are whole. Only a fractional part shuts integer out.
- Pick real whenever a value could ever have a fractional part — a price, a measurement or an average, say.
- Careful with division: two whole numbers can divide to give a fractional answer, like 9 ÷ 2 = 4.5.
Have a goA program shares 10 pizzas equally between 4 friends. Should the variable for 'pizza each' be integer or real?
Real — 10 ÷ 4 = 2.5 pizzas each.
Both inputs are whole, but the answer isn't. Judge the type by what the variable has to hold, not by what went in.
- The wrong type causes errors. Put 7.5 in an integer and, depending on the language, you get an error or a changed, whole value.
- Many languages, Python included, call the real type float. Same type, different name.
The big picture
A data type decides which values a variable is allowed to hold. Real holds numbers that can have a fractional part, like 3.75 or −0.5 — and it holds whole numbers too. Integer holds whole numbers only. So the question to ask is: could this value ever have a fractional part? If yes, pick real. Prices, measurements and averages are the usual suspects, and dividing whole numbers can produce one. Pick the wrong type and the program can go wrong. Many languages call real float: same type, different name.
Key points
Worked example
Problem
A fitness app stores three values: the number of steps walked today, the distance walked in kilometres, and the number of days in a row the user has hit their target. Choose the most suitable data type for each, and justify each choice.
⚠ Watch out
Choosing the type from the one example you're shown instead of every value the variable could ever hold. A price of 3.00 looks whole — but the next one might be 2.35, so price needs real. Averages catch people the same way: whole numbers in, a fraction out.
Memory hook
Point possible? Pick real. (And float is just real's other name.)
Check yourself
Cover the page. Explain out loud why 12 can be stored as a real, but 12.5 can't be stored as an integer. Then name one value from your own day that needs real and one that suits integer.
Flashcards
(10)What is a data type?
What values can the real data type hold?
Can an integer variable hold 12.5?
On a Venn diagram of 'integer can hold it' and 'real can hold it', where do whole numbers go?
What name do many programming languages use for the real type?
Does 'real' mean the value comes from the real world?
Why can dividing two whole numbers mean you need a real?
What can happen if a program tries to put a value with a fractional part into an integer variable?
Does a big number like 250000 need a real?
Name four common data types.
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 postedMore AQA GCSE Computer Science topics
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 26 October 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.