OCR · GCSE · Computer Science
Course version: J277 · Version from Sept 2022
The use of data types Integer Real Boolean Character and string Casting
Full specification wording
Data types: The use of data types Integer Real Boolean Character and string Casting
Data types classify values so a program stores and processes them correctly.
Checked against the OCR J277 specification on .
- 4 key terms
Study notes
From the checked teaching notes for this specification point.
The idea
Data types classify values so a program stores and processes them correctly. 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.
What earns the marks
- 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.
Common mistakes and how to put them right
Treating a string of digits as a number.
Put it right: Cast with int("5") + int("3") to get 8.
Using a real where an integer is required, such as range(3.0).
Put it right: Cast to int(3.0) or use an integer literal.
Assuming Boolean accepts other values such as 1 or "yes".
Put it right: Use only True and False, and cast with bool() only when the conversion rule is understood.
Forgetting that character and string are different.
Put it right: Choose the type that matches the data and the operations needed.
Exam 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.
Try the lesson
The start of the Data types: The use of data types Integer Real Boolean Character and string Casting lesson, made from checked teaching notes for this specification point.
Have a go first
Which data type is most suitable for storing the value 42?
Listen
Data types classify values so a program stores and processes them correctly. 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. A strong answer earns marks for these 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". A common slip: Treating a string of digits as a number: "5" + "3" gives "53". Instead, cast with int("5") + int("3") to get 8. Exam tip: Read the scenario and name the most suitable type for each value before writing code; justify with one short reason.
Key words
Say what each word means before you turn the card.
Integer
Try answering aloud or in your head before turning the card.
Real
Try answering aloud or in your head before turning the card.
Boolean
Try answering aloud or in your head before turning the card.
Casting
Try answering aloud or in your head before turning the card.
See every definition
- Integer
- A data type that holds whole numbers such as 42 or -7, used for counting and exact arithmetic.
- Real
- A data type that holds decimals such as 3.14 or -0.5, for numbers with fractional parts.
- Boolean
- A data type that holds only True or False, used for conditions and flags.
- Casting
- Converts a value from one type to another, for example int("25") turns the string "25" into the integer 25.
There is more to this lesson
The full lesson goes on to check your understanding and help you earn the marks. Create a free account to carry on, with your progress saved.
A week of Premium from your first lesson · Then the free plan continues · No card, no charge
Test your understanding of Data types: The use of data types Integer Real Boolean Character and string Casting
Active recall beats re-reading. Take an instant quiz now to test what you’ve learned and lock it into long-term memory.
A week of Premium from your first lesson · Then the free plan continues · No card, no charge