GCSE · Computer Science · AQA · Spec 8525
Real (float) data type
Four whole-number quiz scores go into a program, and their average comes out as 7.5. Where does that .5 go — and what if it has nowhere to go?
Computer Science · Choosing a type
Whole numbers in, a fraction out
Four quiz scores go in. Step through the program 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 through one line at a time. Every value in the table is worked out for you — check each one in your head.
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 can hold.
- Real holds numbers that can have a fractional part, such as 3.75 or −0.5. It can hold whole numbers too.
- Integer holds whole numbers only, so any value with a fractional part needs real.
- Choose real when a value could have a fractional part — for example a price, a measurement or an average. Dividing whole numbers can give one.
- Using the wrong data type can cause errors, such as trying to keep 7.5 in an integer variable.
- Many programming languages call the real type float. It's the same type with a different name.
The big picture
A data type decides which values a variable can hold. The real data type holds numbers that can have a fractional part, like 3.75 or −0.5, and it can hold whole numbers too. Integer holds whole numbers only. So choose real whenever a value could have a fractional part — prices, measurements and averages are typical. Dividing whole numbers can produce one. Many programming languages call this type float: it's the same type with a 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 given instead of every value the variable could hold. A price of 3.00 looks whole, but the next might be 2.35 — so price needs real. Averages catch people the same way.
Memory hook
Point possible? Pick real. (And float is just real's other name.)
Check yourself
Without scrolling up: why can 12 be stored as a real, but 12.5 can't be stored as an integer? Then name one value 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 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.