Loading...
GCSE OCR Computer Science J277 - Topic 2.2.2: Data Types Exam
Instructions
- This exam consists of 15 questions, including objective (e.g., short-answer, identification) and descriptive (e.g., code-writing, explanation) questions.
- Total marks: 50.
- Time allowed: 45 minutes.
- Answer all questions.
- Use OCR Exam Reference Language (pseudo-code) where code is required, unless specified otherwise.
Questions
Question 1 (2 marks) [Descriptive]
Define what a data type is and explain why it is important in programming.
Question 2 (1 mark) [Objective]
Name the five data types specified in the OCR J277 syllabus.
Question 3 (3 marks) [Objective]
Identify the data type for each of the following values:
a) 42 (1 mark)
b) "Hello" (1 mark)
c) TRUE (1 mark)
Question 4 (2 marks) [Descriptive]
Explain why an integer data type is more appropriate than a string for storing the number of students in a class.
Question 5 (4 marks) [Descriptive]
Write pseudo-code to:
- Declare a constant
MAX_SCORE set to 100.
- Declare a variable
name set to "Alice".
- Declare a variable
passed set to TRUE.
- Output all three values.
Question 6 (4 marks) [Descriptive]
Write pseudo-code (Python code is also an option) to:
- Input a user’s age as a string.
- Cast it to an integer.
- Add 5 to the age.
- Output the result.
Question 7 (3 marks) [Objective]
What data type would you use for the following, and why?
a) A single letter grade (e.g., 'A'). (1 mark)
b) A person’s height in meters (e.g., 1.75). (1 mark)
c) A flag indicating if a game is over. (1 mark)
Question 8 (5 marks) [Descriptive]
Write pseudo-code for a program that:
- Inputs a test score as a string.
- Casts it to a real number.
- Checks if the score is at least 50.
- Sets a Boolean variable
passed accordingly.
- Outputs the score and whether the student passed.
Question 9 (3 marks) [Objective]
What is the purpose of type casting in programming? Give an example in Python.
Question 10 (3 marks) [Objective]
What is the output of this Python code? Explain briefly.
x = "10"
y = int(x) * 2
print(y)
Question 11 (4 marks) [Descriptive]
Write pseudo-code (Python code is also an option) to input two numbers as strings, cast them to floats, calculate their average, and output the result.
Question 12 (3 marks) [Objective]
In the following pseudo-code, identify the data type of each variable:
price ← 19.99
quantity ← 5
description ← "Apples"
a) price (1 mark)
b) quantity (1 mark)
c) description (1 mark)
Question 13 (4 marks) [Descriptive]
Write pseudo-code to:
- Input a character representing a user’s response (e.g., 'Y' or 'N').
- Check if it is 'Y'.
- If true, output "Yes selected"; otherwise, output "No selected".
Question 14 (2 marks) [Descriptive]
Explain the difference between a character and a string data type, with examples.
Question 15 (5 marks) [Descriptive]
Write a pseudo-code (Python code is also an option) that:
- Inputs a user’s name (string) and score (cast to float).
- Sets a Boolean
is_high to True if the score is above 75.
- Outputs a message like "[Name], your score is [score]. High score: [is_high]".
End of Question Paper