Skip to topic
    ← Back to course topics

    Data types and structures — Edexcel GCSE Computer Science

    Test yourself on Data types and structures with PEARSON EDEXCEL GCSE practice questions.

    Start free

    7 days Premium · Then free forever · No card, no charge

    Data types and structures explained

    This topic focuses on the practical application of data types and structures within programming.

    Read the full explanation

    Students must demonstrate the ability to implement primitive data types and structured data types, including one- and two-dimensional arrays, within their code to solve problems.

    Read the Data types and structures study guideFull revision notes for Edexcel GCSE Computer Science

    What to demonstrate

    1. Correct use of primitive data types: integer, real, Boolean, char.
    2. Correct use of structured data types: string, array, record.
    3. Correct implementation of one- and two-dimensional arrays.
    Show all 5 objectives
    1. Appropriate use of variables and constants.
    2. Correct string manipulation techniques including length, position, substrings, and case conversion.

    Data types and structures exam tips

    Topic Overview

    Data types and structures are fundamental to computer science, as they define how data is stored, processed, and manipulated within programs. In the Edexcel GCSE Computer Science specification, this topic covers the different types of data (such as integer, real, Boolean, character, and string) and how data can be organised using structures like arrays (one-dimensional and two-dimensional), records, and files. Understanding these concepts is crucial because they form the building blocks for writing efficient and error-free code, and they appear in both the written exam and the programming project.

    Data types determine what kind of operations can be performed on data and how much memory is used. For example, integers are used for whole numbers, while floats (real numbers) handle decimals. Boolean data types represent true/false values, essential for decision-making in programs. Data structures like arrays allow you to store multiple values under a single variable name, making it easier to manage collections of data. Records group related data of different types together, such as a student record containing a name (string), age (integer), and grade (character).

    This topic is directly linked to programming fundamentals, algorithms, and problem-solving. In the exam, you may be asked to identify appropriate data types for given scenarios, explain the advantages of using arrays, or write code that declares and uses variables of different types. Mastering data types and structures will also help you avoid common errors like type mismatch or index out-of-bounds, which are frequently tested in exam questions.

    Key Concepts
    • →Data types: integer (whole numbers), real/float (decimal numbers), Boolean (true/false), character (single letter or symbol), string (sequence of characters).
    • →Casting: converting one data type to another, e.g., converting a string to an integer using int() in Python.
    • →One-dimensional arrays: a linear collection of elements of the same data type, accessed using an index (starting at 0).
    • →Two-dimensional arrays: an array of arrays, often used to represent tables or grids, accessed with two indices (row and column).
    • →Records: a data structure that groups together related data of different types, often implemented using dictionaries in Python or structs in other languages.
    Marking Points
    • Correct use of primitive data types: integer, real, Boolean, char.
    • Correct use of structured data types: string, array, record.
    • Correct implementation of one- and two-dimensional arrays.
    • Appropriate use of variables and constants.
    • Correct string manipulation techniques including length, position, substrings, and case conversion.
    Examiner Tips
    • 💡Ensure you are familiar with the Programming Language Subset (PLS) as it defines the expected syntax for these structures.
    • 💡Practice string manipulation functions as these are frequently tested in practical programming tasks.
    • 💡Use meaningful identifiers for all variables and constants to improve code readability.
    • 💡Always check the dimensions of an array before attempting to access or iterate through it.
    • 💡Always justify your choice of data type in exam questions. For example, if storing a person's age, use integer because age is a whole number and you won't need decimals. This shows you understand the purpose of each type.
    • 💡When using arrays, remember to check for index out-of-bounds errors. In your code, ensure loops don't exceed the array length (e.g., using len(array) in Python). Examiners look for robust code.
    • 💡For two-dimensional arrays, practice accessing elements using nested loops. A common question is to output the contents of a 2D array row by row. Make sure you can write the code to do this.
    Common Mistakes
    • Confusing the index of an array with the value stored at that index.
    • Incorrectly handling array bounds, leading to runtime errors.
    • Failing to initialize variables before use.
    • Using incorrect data types for specific operations, such as performing arithmetic on strings.
    • Misconception: Strings and characters are the same. Correction: A character is a single letter or symbol (e.g., 'A'), while a string is a sequence of characters (e.g., "Hello"). In Python, a character is just a string of length 1.
    • Misconception: Array indices start at 1. Correction: In most programming languages (including Python, Java, and C++), array indices start at 0. The first element is at index 0, not 1.
    • Misconception: You can store different data types in the same array. Correction: In many languages (like Java and C++), arrays are homogeneous—they can only store elements of the same data type. Python lists can mix types, but arrays (from the array module) are homogeneous.
    Frequently Asked Questions
    What is the difference between a float and an integer in Python?
    An integer (int) is a whole number without a decimal point, like 5 or -3. A float (float) is a number with a decimal point, like 3.14 or -0.5. In Python, dividing two integers using / always returns a float, even if the result is a whole number (e.g., 4/2 = 2.0). You can convert between them using int() and float().
    How do I declare a one-dimensional array in Python?
    In Python, you can create a one-dimensional array using a list. For example: my_array = [10, 20, 30, 40]. Lists are dynamic and can hold mixed data types, but for GCSE you'll usually use homogeneous lists. You can access elements using indices: my_array[0] returns 10. To create an empty list, use my_array = [].
    What is a Boolean data type used for?
    A Boolean data type can only have two values: True or False. It is used in conditional statements (if, while) to control the flow of a program. For example, you might use a Boolean variable to track whether a user is logged in: is_logged_in = True. Booleans are also the result of comparison operators like ==, >, and <.
    How do I store a student's name, age, and grade together?
    You can use a record, which in Python is often implemented as a dictionary. For example: student = {'name': 'Alice', 'age': 15, 'grade': 'A'}. This groups related data of different types under one variable. You can access each field using the key: student['name'] returns 'Alice'. Alternatively, you could use a tuple or a custom class, but dictionaries are straightforward for GCSE.
    Why do array indices start at 0?
    Array indices start at 0 because the index represents an offset from the memory address of the first element. The first element is at offset 0, so its index is 0. This is a convention in most programming languages (C, Java, Python) and makes memory addressing efficient. For example, if an array starts at memory address 100, the element at index 0 is at address 100, index 1 at 104 (if each element is 4 bytes), and so on.
    What is the difference between a one-dimensional and a two-dimensional array?
    A one-dimensional array is like a list of items, e.g., [1, 2, 3]. A two-dimensional array is like a table with rows and columns, e.g., [[1, 2], [3, 4]] has 2 rows and 2 columns. To access an element in a 2D array, you need two indices: array[row][column]. For example, array[0][1] returns the element in the first row, second column (2). Two-dimensional arrays are useful for representing grids, matrices, or game boards.