Exam-style question
Try this first
In Python, which expression accesses the value in row 2 and column 3 of a two-dimensional array called matrix, using zero-based indexing?.
- A.matrix[2][3]
- B.matrix[3][2]
- C.matrix[2, 3, 0]
- D.matrix[23]
Model answer
What a good answer should say
- matrix[2][3]
Explanation
Why this works
In a Python representation of a two-dimensional array, the first index selects the row and the second index selects the column. With zero-based indexing, row 2 and column 3 are written as matrix[2][3].
Common mistake
No common mistake is linked to this question yet.
