Integer, Real/Float, Boolean, Character, String. (1 mark for all five correct.)
a) Integer (1 mark)
b) String (1 mark)
c) Boolean (1 mark)
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.)
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.)
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.)
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)
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.)
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.)
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.)
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.)
a) price: Real/Float (1 mark)
b) quantity: Integer (1 mark)
c) description: String (1 mark)
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.)
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.)