ProceduralOCR J277
DashboardCoursePracticeReviewProgressGlossary
Saved on this deviceContinue learning

Procedural · OCR J277 programming practice

Progress stays in this browser unless you export it.

Course/Strings & arrays/Two-dimensional arrays
J277 · 2.2.3

Unit 8 · Lesson 6

Two-dimensional arrays

Lesson progress0 / 7

Build the idea

Start with the concept and its key vocabulary.

Key idea

Access and traverse 2D arrays as tables, then cast numeric strings before calculations.

A 2D array is a table addressed with two indices. The first chooses a row and the second chooses a column. OCR writes table[row,column], while Python uses table[row][column]. Rows can represent records and columns fields. Use a nested loop to visit every cell: the outer loop selects each row and the inner loop selects each column. If every array value is stored as text, cast numeric fields before calculating.

Two-dimensional array

An array of arrays arranged like a table with rows and columns.

Row

A horizontal group in a table; it can represent one record.

Column

A vertical group in a table; it can represent one field.

Record

A group of related field values describing one entity.

Field

One category of data within a record.

Keep these in mind

  • Both row and column indices start at zero.
  • OCR separates two indices with a comma inside one pair of brackets.
  • Python uses one bracket pair for the row and a second for the column.
  • Nested loops can traverse every row-column combination.
  • Use int() or float() before arithmetic on numeric text fields.

Learning objective

Access and traverse 2D arrays as tables, then cast numeric strings before calculations.

Exam tip

Annotate the table with row and column numbers before reading an element. Then check whether the retrieved field needs casting.

Common mistake

Swapping row and column indices retrieves a different field or may go out of bounds. Use table[row][column] in that order.

PreviousNext