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

Which type could hold it?

Think of each data type as a set of values it can hold. For every value below, tick each set it belongs to. It can go in both circles, one circle, or neither.

  • 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 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 through one line at a time. Every value in the table is worked out for you — check each one in your head.

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

Watch out: If average had been an integer variable, it couldn't hold 7.5. Depending on the language, the program would either stop with an error or change the value to a whole number — and output 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.

Which idea is closest to what you think right now?
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 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

1Ask one question: 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 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?
It sets which values a variable can 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 too.
Can an integer variable hold 12.5?
No. Integer holds whole numbers only. 12.5 has a fractional part, so 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, so the integer-only region stays empty.
What name do many programming languages use for the real type?
Float. It's the same data type with a different name.
Does 'real' mean the value comes from the real world?
No. It means a number that can have a fractional part.
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 is 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. Size doesn't decide the type — a fractional part does.
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 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.