GGCSE Revision Hub

3.2.1 Data types

AQA Computer Science 8525Topic 3.2 — ProgrammingFoundation & Higher

This is the longest topic in the specification and the one that carries most of the Paper 1 marks. It covers the statements every program is built from, the operators that do the work, the structures that hold data, and the discipline that makes code safe to rely on. Two of the specification's supported languages are Python and C#, so the examples here use Python-style syntax with the AQA pseudo-code where the specification demands it. Learn this as something you write, not something you memorise.

What you need to know

What a data type is

A data type tells the computer what kind of value a variable holds and how it should be treated. It is what stops the program trying to add a number to a word, and it is what tells the interpreter how many bits to reserve. Every variable, every constant and every parameter has one.

Key fact: A data type says what kind of value a variable holds and how it should be treated.

The five types you must use

Understand and use appropriately: integer, real, Boolean, character and string. An integer is a whole number with no decimal point. A real is a number that can have a decimal point. A Boolean is a value with two states, True or False. A character is a single symbol, and a string is a sequence of characters.

Key fact: Five types: integer, real, Boolean, character and string.

Integer against real

The distinction is not cosmetic. If you store 3 as an integer and then divide it by 2, you get 1 with a remainder of 1; if you store it as a real, you get 1.5. Choosing the wrong type is a common cause of logic errors, and the spec is explicit that integer division and real division are different operations.

Key fact: 3 INT 2 is 1 with remainder 1; 3 / 2 as a real is 1.5.

Character against string

A character is one symbol — 'A', '7', '?', a space. A string is a sequence of characters in quotes: "Hello". In Python a single character and a one-character string are written differently ('A' and "A"), and the spec treats them as different types, so be careful when a question asks for a character.

Key fact: A character is one symbol; a string is a sequence of characters written in quotes.

Boolean

A Boolean has only two possible values: True or False. It is the type behind every condition. A comparison such as score > 50 does not give you a number; it gives you a Boolean, and that Boolean is what the IF statement tests. Get the type right and the rest of the selection structure follows.

Key fact: A Boolean is True or False, and it is what a comparison produces.

The same type, different names

Depending on the actual programming language being used, these data types may have other names. Real numbers may be described as float. In exams we will use the general names given opposite: integer, real, Boolean, character and string. So if a question says 'real', write real; if it says 'float' because it is showing Python, accept float — but do not mix the two in one answer.

Key fact: In exams use the general names: integer, real, Boolean, character, string.

Flashcards

Exam questions

Written in the style of AQA Computer Science, with a mark scheme for each one. No question here is a real past paper question.

mcq1 mark

Which data type would you use for a value that can only be True or False?

  • Integer
  • Real
  • Boolean
  • Character

Mark scheme: 1 mark for identifying Boolean, which has exactly two possible values. An integer is a whole number, a real can have a decimal point and a character is a single symbol.

short3 marks

Explain in English why the data type of a variable matters, and give one example where the wrong choice changes the answer.

Mark scheme: 1 mark for explaining that the type tells the computer how to treat and store the value. 1 mark for giving a correct example, such as 11 stored as an integer and divided by 2 giving a quotient of 5 with remainder 1, while the same value as a real divided by 2 gives 5.5. 1 mark for explaining that the wrong type therefore produces a wrong result rather than an error message.

six6 marks

Explain in English the five data types in the specification and how you would choose between them.

Mark scheme: Level 1 (1-2 marks): A short answer naming two or three of the types. Level 2 (3-4 marks): A structured answer covering all five with examples of each. Level 3 (5-6 marks): A detailed answer defining each of the five types with a suitable example, explaining that a Boolean is what a comparison produces and is therefore what selection and iteration conditions test, explaining that character and string are different types even when the string has one character, and explaining that the choice of type affects the arithmetic as well as the storage, since integer and real division behave differently.

Other sections in this topic

Practise these questions

Answer them in the interactive view and they get marked against the same mark scheme, one mark at a time, with the reason for each mark.

Open the interactive topic →