A cinema gives a 50% discount to tickets if the user is under 18 OR 65 and over. Full price is £10. Write an algorithm that asks the user for their age, and outputs the final price they must pay.
Exam Finished
Because free-text code answers cannot be perfectly auto-marked, please self-assess your answers against the official mark scheme below.
Mark Scheme
Q1. Trace Answer (2 marks)
Answer: 6
(1 mark for working out it loops 1,2,3. 1 mark for the final correct sum).
Q2. Debug Answer (3 marks)
Error 1: Line 02 uses = (assignment) instead of != (not equal). If it's a WHILE loop, we want to loop while it is NOT correct.
Error 2: Line 04 uses endfor but the loop started with while. It should be endwhile.
Error 3: Optional/Alternative for Line 02. The logic is inverted. It stops immediately instead of looping.
Q3. Algorithm Answer (6 marks)
ageStr = input("Age?")
age = int(ageStr)
if age < 18 OR age >= 65 then
print("Price: £5")
else
print("Price: £10")
endif
(2 marks for inputs & casting, 2 marks for correct IF statement with OR, 2 marks for correct logic structure and printing).