Data types, arrays and records

GCSE Computer Science revision notes, key terms and practice questions.

Data types

  • Integer: a whole number, such as 42. Real (also called float): a number with a decimal part, such as 3.14. Boolean: True or False.
  • Character: a single letter, digit or symbol, such as 'A'. String: a sequence of characters, such as "Hello".
  • Choosing the right type saves memory and avoids errors. A phone number is stored as a string, because it can start with 0 and is never used in calculations.

Casting

  • Casting converts data from one type to another: int("42") gives the integer 42, and str(42) gives the string "42".
  • Input from the keyboard is a string, so cast it to a number before doing maths with it.

Arrays

  • An array stores several values of the same type under one name. Each value has an index, which usually starts at 0: names[0] is the first item.
  • A 2D array is like a table, and needs two indexes, such as grid[row][column]. Check the question to see which index comes first.
  • In many languages an array has a fixed size. Python uses lists, which can grow and shrink.

Records

  • A record groups related data of different types into fields. A student record might have a name (string), an age (integer) and whether they have paid (Boolean).

Key terms

Integer
A whole number.
Real
A number with a decimal part (also called a float).
Boolean
A data type with only two values: True or False.
Character
A single letter, digit or symbol.
String
A sequence of characters, such as a word or sentence.
Casting
Converting data from one data type to another.
Array
A data structure that stores several values of the same type under one name.
Index
The position of an item in an array, usually counted from 0.
Record
A data structure that groups related fields of different types.

Practise Data types, arrays and records: 12 questions