Question 1
1 markA teacher stores the marks of four students in three tests in a two-dimensional array. Each inner array holds one student's marks.
marks ← [[12, 15, 9], [18, 7, 14], [11, 20, 16], [8, 13, 19]]Which expression evaluates to 14?
Choose your answer.
- marks[2][1]
- marks[1][2]
- marks[0][2]
- marks[2][2]
Model answer
marks[1][2]
Explanation
The first index chooses the inner array (the student) and the second index chooses the element within it (the test), both counting from 0. 14 is in the second inner array, index 1, at position 2, so it is marks[1][2]. marks[2][1] swaps the two indexes and gives 20, which is a common mistake.
Mark scheme
-
1 mark
marks[1][2]
If more than one option is given, 0 marks. Mark is for AO2 (apply).