2D Array Workbench

2D arrays: a table with two indexes

Click cells, trace nested loops line by line, and see the exam questions OCR asks. Switch between GCSE (J277, topic 2.2.3) and A Level (H446, topic 1.4.2), and between OCR's exam notation and Python.

The array

Reading an index

  1. The first number picks the row (count down from 0).
  2. The second number picks the column (count across from 0).
  3. Where they cross is the element. name[2, 3] is the fourth element of the third row, because counting starts at 0.
  4. If a question defines its own order, such as "grid[x, y] where x is the column", follow the question.

Click any element


    
Exam tips and common mistakes