Loading...

My Learning Pad Login

Welcome

GCSE OCR Computer Science J277 - Topic 2.2.2: Data Types Exam - Answers

Answers and Explanations

Question 1 (2 marks)

Question 2 (1 mark)

Integer, Real/Float, Boolean, Character, String. (1 mark for all five correct.)

Question 3 (3 marks)

a) Integer (1 mark)
b) String (1 mark)
c) Boolean (1 mark)

Question 4 (2 marks)

An integer is appropriate because the number of students is a whole number and supports mathematical operations (e.g., addition). A string would treat it as text, preventing calculations. (1 mark for integer choice, 1 for explanation.)

Question 5 (4 marks)

MAX_SCORE ← 100
name ← "Alice"
passed ← TRUE
OUTPUT(MAX_SCORE, name, passed)

(1 mark for constant, 1 for name, 1 for Boolean, 1 for output.)

Question 6 (4 marks)

age = input("Enter your age: ")  # String input
age = int(age)                   # Cast to integer
result = age + 5                 # Add 5
print(result)                    # Output result

(1 mark for input, 1 for casting, 1 for calculation, 1 for output.)

Question 7 (3 marks)

a) Character: A single letter like 'A' is one symbol. (1 mark)
b) Real/Float: Height (e.g., 1.75) includes decimals for precision. (1 mark)
c) Boolean: Game over status is either true or false. (1 mark)

Question 8 (5 marks)

score ← INPUT("Enter test score: ")
score ← REAL(score)
passed ← score >= 50
OUTPUT("Score: ", score)
OUTPUT("Passed: ", passed)

(1 mark for input, 1 for casting, 1 for condition, 1 for Boolean, 1 for outputs.)

Question 9 (3 marks)

Type casting converts data from one type to another to enable operations. (1 mark)
Example: num = int("5") converts string "5" to integer 5 for calculations. (2 marks for example and explanation.)

Question 10 (3 marks)

Output: 20
Explanation: x is string "10"; int(x) converts to integer 10; multiplying by 2 gives 20, printed by print(y). (2 marks for output, 1 for explanation.)

Question 11 (4 marks)

num1 = float(input("Enter first number: "))  # Input and cast
num2 = float(input("Enter second number: ")) # Input and cast
average = (num1 + num2) / 2                 # Calculate average
print(average)                              # Output result

(1 mark for inputs, 1 for casting, 1 for calculation, 1 for output.)

Question 12 (3 marks)

a) price: Real/Float (1 mark)
b) quantity: Integer (1 mark)
c) description: String (1 mark)

Question 13 (4 marks)

response ← INPUT("Enter response (Y/N): ")
IF response = 'Y' THEN
    OUTPUT("Yes selected")
ELSE
    OUTPUT("No selected")
ENDIF

(1 mark for input, 1 for condition, 1 for outputs, 1 for structure.)

Question 14 (2 marks)

Question 15 (5 marks)

name = input("Enter your name: ")
score = float(input("Enter your score: "))
is_high = score > 75
print(f"{name}, your score is {score}. High score: {is_high}")

(1 mark for name input, 1 for score input/cast, 1 for Boolean, 1 for output, 1 for structure.)