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 · Data types

Which type could hold it?

Here's the trick: think of each data type as a club, and its members are the values it can hold. For every value below, tick each club it belongs to. A value can join both, one, or neither. Try them all before you check.

  • A An integer can hold it
  • B A real can hold it
  1. 7
  2. 3.75
  3. −12
  4. 0.5
  5. 0
  6. 250000
  7. −2.25
  8. seven (the word)
  9. True

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 + 7
2 count ← 4
3 average ← total / count
4 OUTPUT average
totalcountaverage
30

Output

 

Step 1: Four whole numbers add up to a whole number: 30. An integer is fine for total.

1 / 4

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.

Step 1 of 4: Four whole numbers add up to a whole number: 30. An integer is fine for total..

Watch out: Now imagine average had been an integer variable. It can't hold 7.5. Depending on the language, the program either stops with an error or changes the value to a whole number — and outputs the wrong average. That's what using the wrong data type looks like.

Computer Science · Names

Real or float — what's the difference?

Maya learned to program in Python, where a number like 7.5 is called a float. Her revision notes call the same kind of number a real. She's now slightly worried she's been learning the wrong thing.

Which idea is closest to what you think right now? Be honest — nobody's watching.
How sure are you?
UK note

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.

Computer Science · Your turn

Choose it, then justify it

A café's till program stores three values: the number of cups sold today, the price of one cup in pounds (for example 2.35), and the temperature of the coffee in °C, measured to one decimal place (for example 71.4). Choose the most suitable data type for each value, and justify each choice. [6 marks]

0 words · your answer stays on this page and is not sent anywhere.

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

1One question decides it: could this value ever have a fractional part? Yes → real.
2Whole numbers fit in real as well as integer — but a value with a fractional part doesn't fit in integer.
3Size and sign don't decide the type. 250000 and −12 are whole, so integer can hold them.
4Float and real: two names, one type.

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?
The rule for which values a variable is allowed to hold.
What values can the real data type hold?
Numbers that can have a fractional part, like 3.75 or −0.5 — and whole numbers as well.
Can an integer variable hold 12.5?
No. Integer is whole numbers only, and 12.5 has a fractional part — it needs real.
On a Venn diagram of 'integer can hold it' and 'real can hold it', where do whole numbers go?
In the overlap. Both types can hold them — which leaves the integer-only region empty.
What name do many programming languages use for the real type?
Float. It's the same data type wearing a different name.
Does 'real' mean the value comes from the real world?
No. It means a number that can have a fractional part — wherever it came from.
Why can dividing two whole numbers mean you need a real?
The answer can have a fractional part: 7 divided by 2 is 3.5.
What can happen if a program tries to put a value with a fractional part into an integer variable?
Depending on the language, an error — or the value gets changed to a whole number. Either way, the program goes wrong.
Does a big number like 250000 need a real?
No. It's whole, so an integer can hold it. A fractional part decides the type, not size.
Name four common data types.
Integer, real (float), string and Boolean.

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 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.