Question 1
4 marksA cinema sells adult tickets for £9.50 each and child tickets for £6.00 each.
Write a program, using OCR Exam Reference Language or a high-level programming language, that:
- asks the user to enter the number of adult tickets
- asks the user to enter the number of child tickets
- calculates the total cost of the tickets
- outputs the total cost.
Model answer
adults = int(input("Number of adult tickets: "))
children = int(input("Number of child tickets: "))
total = adults * 9.50 + children * 6.00
print("Total cost: £" + str(total))
Explanation
input always returns a string, so both values are cast with int() before any arithmetic. Multiplication is done before addition, so adults * 9.50 + children * 6.00 needs no brackets. Adding the numbers of tickets first and multiplying by one price is wrong because the two kinds of ticket cost different amounts. For 2 adults and 1 child the program outputs 25 (2 × 9.50 + 6.00).
Mark scheme
-
1 mark
inputs the number of adult tickets and the number of child tickets (two separate inputs)
Answers must be in OCR Exam Reference Language or a high-level programming language (e.g. Python); pseudocode, natural English or bullet points score 0. Ignore minor syntax errors. Accept any variable names and any (or no) prompt text. Both inputs are needed for this mark.
-
1 mark
converts (casts) both inputs to numbers, e.g. adults = int(input(...))
accept int(), float() or real(). Do not award if either input is left as a string.
-
1 mark
calculates the total correctly: adults × 9.50 + children × 6.00
e.g. total = adults * 9.50 + children * 6. Accept 9.5 and 6, any order, one step or several (e.g. adultCost and childCost added together). Do not accept (adults + children) * 9.50 or other calculations that give a wrong total. Award this mark even if the inputs were not cast - missing casting is penalised only at mark point 2.
-
1 mark
outputs the calculated total
e.g. print(total), print("Total cost: £" + str(total)) or print("Total:", total). Accept printing the calculation directly. The value output must be the calculated total. Treat a missing str() in the output message as a minor error. No currency formatting is needed. Award this mark even if the inputs were not cast - missing casting is penalised only at mark point 2.