Skip to topic
    ← Back to course topics

    Data types — OCR GCSE Computer Science

    Teaching note checked against the official specification.

    Test yourself on Data types with OCR GCSE practice questions.

    Start free

    A week of Premium from your first lesson · Then the free plan continues · No card, no charge

    Data types explained

    Data types classify values so a program stores and processes them correctly.

    Read the full explanation

    Integer holds whole numbers such as 42 or -7; real holds decimals such as 3.14 or -0.5; Boolean holds only True or False; character holds one symbol such as 'A' or '7'; string holds text such as "Hello". Casting converts a value from one type to another, for example int("25") turns the string "25" into the integer 25, while str(25) turns 25 into "25". Casting is essential when input arrives as a string but arithmetic is needed, or when joining numbers into output text. Choosing the wrong type causes errors: adding "5" + "3" concatenates to "53", not 8. Use int() for whole numbers, float() for decimals, str() for text and bool() for truth values, and validate input before casting.

    Read the Data types study guideFull revision notes for OCR GCSE Computer Science

    Your focus

    1. Select an appropriate data type for a given value or variable and justify the choice.
    2. Perform casting between integer, real, Boolean, character and string types in short programs.
    3. Diagnose and correct type-related errors such as concatenation instead of addition or invalid casts.

    Data types exam tips

    Marking Points
    • Identifies integer as a whole number type used for counting and exact arithmetic, e.g. score = 10.
    • Identifies real (float) as a type for numbers with fractional parts, e.g. price = 2.99.
    • Identifies Boolean as a type with exactly two values, True and False, used for conditions and flags.
    • Identifies character as a single symbol and string as a sequence of characters, e.g. 'A' versus "Apple".
    • Explains that casting changes a value's type, e.g. int("7") produces 7 and str(7) produces "7".
    • Applies casting to solve a problem, such as converting input before arithmetic or converting a number before concatenation.
    • Recognises that invalid casts raise errors, e.g. int("hello") fails because the string is not numeric.
    Examiner Tips
    • 💡Read the scenario and name the most suitable type for each value before writing code; justify with one short reason.
    • 💡When a question shows input followed by arithmetic, check whether casting is needed and state the cast explicitly.
    • 💡For casting questions, trace the value step by step and show the type after each conversion, not just the final value.
    • 💡Use British English spelling such as 'character' and 'Boolean', and write code in a clear, indented style.
    Common Mistakes
    • Treating a string of digits as a number: "5" + "3" gives "53". Correction: cast with int("5") + int("3") to get 8.
    • Using a real where an integer is required, such as range(3.0). Correction: cast to int(3.0) or use an integer literal.
    • Assuming Boolean accepts other values such as 1 or "yes". Correction: use only True and False, and cast with bool() only when the conversion rule is understood.
    • Forgetting that character and string are different: 'A' is one character, "A" is a string of length 1. Correction: choose the type that matches the data and the operations needed.