Key Terms
- Integer: A whole number, positive or negative, with no decimal point (e.g. -5, 0, 42)
- Real / Float: A number with a decimal point (e.g. 3.14, 19.99)
- String: A sequence of characters enclosed in quotes (e.g. "Hello")
- Character: A single letter, digit, or symbol enclosed in apostrophes (e.g. 'A')
- Boolean: A value that is either true or false only
- Type casting: Converting a value from one data type to another
Must-Know Facts
- "42" (string) and 42 (integer) are different โ you cannot add them without casting
- 'A' (one character) and "A" (string of length 1) are different types
- Real/float uses more memory than integer
- Booleans are used in conditions:
if loggedIn == true then - Type casting:
int("42")converts string to integer;str(42)converts integer to string int(3.9)truncates to 3 โ it does NOT round
Key Concepts
- Choose integer for counting whole items; real for measurements or money
- Use string for names, addresses, passwords โ any text
- Boolean used in selection and iteration conditions
- Cast before arithmetic:
int(userInput) + 5notuserInput + 5
Common Mistakes
- Not casting user input before arithmetic: User input is always a string โ you must cast to integer or real before doing maths:
int(input("Age: ")) - Confusing integer and real: Integer stores whole numbers only; real/float stores decimal values โ using integer for money (e.g. 4.99) will truncate the decimal part
- Thinking int() rounds a decimal:
int(3.9)gives 3, not 4 โ integer casting truncates (removes the decimal) rather than rounding - Confusing character and string: A character is a single symbol (one letter or digit); a string is a sequence of characters โ they are different data types
- Using a string to store a number you will calculate with: "42" stored as a string cannot be used in arithmetic โ always use integer or real for values you need to calculate with
This topic summary covers Knowledge Organiser: Data Types within Data Types for GCSE Computer Science. Revise Data Types in 3.2 Programming for GCSE Computer Science with 19 exam-style questions and 10 flashcards. This is a high-frequency topic, so it is worth revising until the explanation feels precise and repeatable. It is section 9 of 9 in this topic. Use this topic summary to connect the idea to the wider topic before moving on to questions and flashcards.
Practice questions for Data Types
Which data type is most appropriate for storing a student's age?
A programmer is creating a system to track gym members. State the most appropriate data type for each of the following and justify your choice: (a) the member's surname, (b) the number of visits this month, (c) whether the membership is active.