Skip to content
VirtusAcademy

Data Types

FoundationHigherAQA

Understand Data Types for GCSE Computer Science with this free worksheet and full mark scheme — Foundation and Higher exam-style questions with worked answers for AQA GCSE Computer Science (8525). Common data types are integer, real, Boolean, character and string.

Free downloads

These worksheets and mark schemes are original, written for Virtus Academy and checked against the current AQA specification. Every worksheet comes with a full mark scheme.

Topic overview

A data type defines what kind of value a variable can hold and what operations can be performed on it.

Five types are required. Integer holds whole numbers such as 42. Real, sometimes called float, holds numbers with a decimal part such as 3.14. Boolean holds only True or False. Character holds a single character such as 'A'. String holds a sequence of characters such as "hello".

Choosing the right type matters for memory and for correctness. An integer uses less memory than a real, so a variable counting items should be an integer. And 5 stored as a string cannot be used in arithmetic — "5" + "3" concatenates to "53" rather than adding to 8, which is a frequent source of bugs.

Revision notes

The five data types

Integer: whole numbers, such as 42 or −7.

Real (or float): numbers with a decimal part, such as 3.14. Boolean: True or False only. Character: a single character, such as 'A'. String: a sequence of characters, such as "hello".

Choosing the right type

An integer uses less memory than a real, so use it when values are whole.

A Boolean uses the least memory of all and should be used for yes or no values rather than storing the strings "yes" and "no".

Type errors

A number stored as a string cannot be used in arithmetic.

"5" + "3" concatenates to "53" rather than adding to 8. Casting converts between types — int("5") gives the integer 5, allowing arithmetic to work correctly.

Key points

  • A data type defines what values a variable can hold.
  • Integer holds whole numbers.
  • Real holds numbers with a decimal part.
  • Boolean holds True or False only.
  • String holds a sequence of characters.
  • Casting converts between data types.

Worked examples

Example 1

State the most appropriate data type for storing a person's age in whole years. [2 marks]

Working

Integername the data type
because age in whole years is a whole number and an integer uses less memory than a realgive the justification

Example 2

Explain what happens when the strings "5" and "3" are added together. [2 marks]

Working

They are concatenated rather than added, giving "53"state the result
because the + operator joins strings rather than performing arithmetic on themexplain why

Example 3

State the most appropriate data type for storing whether a user is logged in. [2 marks]

Working

Booleanname the data type
because the value can only be True or False, and a Boolean uses the least memorygive the justification

Common mistakes

  • Storing numbers as strings.

    They cannot then be used in arithmetic without casting.

  • Using a real when an integer would do.

    Reals use more memory and are unnecessary for whole numbers.

  • Confusing character with string.

    A character is a single symbol; a string is a sequence.

  • Naming a type without justifying it.

    Questions usually want the reason as well.

Exam tips

  • Justify every data type choice.
  • Use Boolean for yes or no values.
  • Watch for numbers stored as strings.
  • Remember integers use less memory than reals.

Key terms

Data type
A definition of what values a variable can hold.
Integer
A whole number data type.
Boolean
A type holding only True or False.
Casting
Converting a value from one data type to another.

Written and reviewed against the current AQA specification. Spotted an error? Let us know.