Signed up recently but had issues with the confirmation email?

Click Forgot password and follow the reset steps. You can choose the same password you used when you signed up. This should then provide access.

Remember to check Spam and Junk. The email will be from auth@progressbytes.co.uk.

Revision notesQuestionsFor schools
Revise Computing
Log inStart revising free
Revision notesQuestionsFor schoolsLog in
GCSE Computer Science/Paper 2/Additional Programming Techniques

one-dimensional (1D)

The use of arrays (or equivalent) when solving problems: one-dimensional (1D)

2.2.3 Additional Programming Techniques

Practise exam questions

Additional Programming Techniques — Note 6 of 13

Arrays as fixed length or static structures

What you need to know

A one-dimensional (1D) array is a data structure that stores a fixed-size collection of elements of the same data type under a single name. Each element is accessed using an index (position number), starting from 0. Arrays are static, meaning their size cannot change once they are created.

What to know

  • Arrays store multiple items of the same data type under one name.
  • Elements are accessed using an index, starting from 0 (zero-indexed).
  • ![1D array indexes from 0, and a 2D array where scores[1][2] is week 2, Wednesday](/knowledge/unit-2-knowledge-images/arrays-1d-2d.svg)
  • Arrays are static (fixed size): their length is set when created and cannot change.
  • Declaring: array names[5] creates an array with 5 elements (index 0 to 4).
  • Assigning: names[0] = "player1" puts "player1" at position 0.
  • Arrays are useful for storing lists of data, for example scores, names or colours.
  • You can loop through an array using a FOR loop: for i = 0 to players.length - 1.
  • Python lists are used to mimic arrays. Lists can change size, but in exam answers treat an array as a fixed size.
  • len(scores) gives the number of items, so for i in range(len(scores)): visits every index. This is safer than hard-coding range(3), which breaks if the array changes size.
  • Found Flag: set found = False before the loop, set it to True inside the loop when a match is found, then report the result AFTER the loop has finished.

Code examples

1D array operations (OCR Exam Reference Language)
text
// Create and access a 1D array
array scores = [10, 20, 30, 40, 50]

print(scores[0])   // 10 (first element)
print(scores[2])   // 30 (third element)
scores[1] = 25     // update the second element

// Loop through the array: the counter is the index
for i = 0 to 4
    print("Index " + str(i) + ": " + str(scores[i]))
next i
1D array operations
python
# Create and access a 1D array (list in Python)
scores = [10, 20, 30, 40, 50]

print(scores[0])   # 10 (first element)
print(scores[2])   # 30 (third element)
scores[1] = 25     # Update second element

# Loop through the array
for i in range(len(scores)):
    print("Index " + str(i) + ": " + str(scores[i]))
Array basics: define, access, loop, change
python
scores = [4, 7, 8]     # define an array

print(scores[1])        # 7: index 1 is the SECOND element

for i in range(len(scores)):   # index 0, 1, 2
    print(scores[i])           # print each item

scores[0] = 10          # replace the first element (index 0) with 10
Total and average of an array (OCR Exam Reference Language)
text
array scores = [4, 7, 8]
total = 0                   // running total

for i = 0 to 2              // indexes 0, 1, 2
    total = total + scores[i]
next i

average = total / 3
print("Total: " + str(total))       // Total: 19
print("Average: " + str(average))   // Average: 6.333...
Total and average of an array
python
scores = [4, 7, 8]
total = 0                      # running total

for i in range(len(scores)):   # loop through each index
    total += scores[i]         # add each score to the total

average = total / len(scores)
print("Total:", total)         # Total: 19
print("Average:", average)     # Average: 6.333...
Check if a value appears in an array (OCR Exam Reference Language)
text
array scores = [12, 7, 5, 10, 3, 2, 7]
target = 7        // the value we are searching for
found = False     // flag: nothing found yet

for i = 0 to 6
    if scores[i] == target then
        found = True  // set the flag when a match is found
    endif
next i

if found == True then   // checked AFTER the loop
    print("Found")
else
    print("Not found")
endif
Check if a value appears in an array
python
scores = [12, 7, 5, 10, 3, 2, 7]
target = 7       # the value we are searching for
found = False    # flag: nothing found yet

for i in range(len(scores)):
    if scores[i] == target:
        found = True   # set the flag when a match is found

if found:              # checked AFTER the loop
    print("Found")
else:
    print("Not found")
Count how many times a value appears (OCR Exam Reference Language)
text
array scores = [12, 5, 10, 6, 7, 12]
target = 12
count = 0         // how many times the target appears

for i = 0 to 5
    if scores[i] == target then
        count = count + 1   // add 1 on each match
    endif
next i

print("Appears " + str(count) + " times")   // Appears 2 times
Count how many times a value appears
python
scores = [12, 5, 10, 6, 7, 12]
target = 12
count = 0        # how many times the target appears

for i in range(len(scores)):
    if scores[i] == target:
        count += 1   # increase the count on each match

print("Appears", count, "times")   # Appears 2 times

Exam technique

  • Tip:A FOR loop iterating through an array should use the loop counter as the INDEX: if the counter is called p, write players[p], NOT players[i].
  • Tip:Off-by-one errors are common. If the array has 6 elements (index 0-5), the loop should go 0 to 5. Python's range(6) gives 0-5.
  • Tip:players.length returns the number of elements. To loop from 0, use for i = 0 to players.length - 1.
  • Tip:scores = [3, 6, 6, 9, 2, 8] → scores[2] = 6 (third element, 0-indexed). Remember arrays are ZERO-INDEXED.
  • Tip:To count only the items that meet a condition (for example the scores of 10 or more), put count = count + 1 INSIDE an if. Work through the array that already holds the data: don't input new values. Any attempt at a loop and at an if earns marks, so always try.
  • Mistake:Putting else: print("Not found") inside the loop prints 'Not found' once for every item that doesn't match.
  • Example:Counting high scores in array scores[6]: for i = 0 to 5, if scores[i] >= 80 then count = count + 1, endif, next i. The counter i is the array INDEX, so each pass checks a different element.

Ready to test yourself?

Practise 2.2.3 questions
← Previous noteSQL to search for data2.2.3 Additional Programming TechniquesNext note →two-dimensional arrays(2D)2.2.3 Additional Programming Techniques

Back to Additional Programming Techniques

Revise another OCR GCSE topic: Programming Fundamentals

Additional Programming Techniques

Note 6 of 13

  1. 1Concatenation
  2. 2slicing
  3. 3ASCII Conversion
  4. 4Open, Read, Write, Close
  5. 5Records to store data
  6. 6SQL to search for data
  7. 7one-dimensional (1D)
  8. 8two-dimensional arrays(2D)
  9. 9Sub programs (functions and procedures) to produce structured code
  10. 10local variables
  11. 11global variables
  12. 12arrays
  13. 13Random number generation
Topic overview

© 2026 Revise Computing · revisecomputing.co.uk

Worried about something?Question Bank UpdatesPrivacy noticeTermsContact

Revise Computing is an independent revision resource. It is not affiliated with, or endorsed by, OCR (Oxford Cambridge and RSA Examinations).