Knowledge Organiser: Data Types
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 (e.g. "Hello")
- Character: A single letter, digit, or symbol (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 character is one symbol; a string is a sequence of characters and can have length 1. The quote style does not decide the type: in Python, "A" and 'A' are both strings
- Real numbers usually need more memory than integers; the exact size depends on the language
- Booleans are used in conditions. OCR pseudocode: if loggedIn == true then. Python: if logged_in == True:
- Type casting, Python: 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 (Python): int(userInput) + 5 not userInput + 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. Python: 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 (it can have length 1)
- 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