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/One-dimensional arrays
J277 · 2.2.3

Unit 8 · Lesson 4

One-dimensional arrays

Lesson progress0 / 7

Build the idea

Start with the concept and its key vocabulary.

Key idea

Use zero-based indices to create, read and change values in a 1D array.

An OCR 1D array stores several values of one type under one name and has a fixed size. Its indices begin at zero, so array names[5] has positions 0 to 4. Python uses lists for the equivalent practical tasks, although Python lists can resize.

Data structure

A method of organising and storing data so it can be accessed and used.

One-dimensional array

A fixed-size linear collection of values of one data type under one name.

Element

One value stored in an array.

Index

The zero-based position used to access an array element.

Keep these in mind

  • OCR declares an empty array with array name[size].
  • OCR also permits an array to be declared with assigned values.
  • Use square brackets containing an index to read or update one element.
  • An array of length five has no element at index five.

Learning objective

Use zero-based indices to create, read and change values in a 1D array.

Exam tip

Convert an ordinal position to an index carefully: the first item is index 0, the third item is index 2.

Common mistake

Using the array length as an index goes one position beyond the end. The last valid index is length - 1.

PreviousNext