Revise Computing
Revision notesQuestionsFor schools
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 12

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] = "Alice" puts "Alice" at position 0.
  • Arrays are useful for storing lists of data, e.g. scores, names, or colours.
  • You can loop through an array using a FOR loop: for count = 0 to theTeam.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.

Exam technique

  • Tip:A FOR loop iterating through an array should use the loop counter as the INDEX: theTeam[count], NOT theTeam[i] if the counter is called count.
  • 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:theTeam.length returns the number of elements. To loop from 0, use for i = 0 to theTeam.length - 1.
  • Tip:scores = [3, 6, 6, 9, 2, 8] → scores[2] = 6 (third element, 0-indexed). Remember arrays are ZERO-INDEXED.
  • Mistake:Putting else: print("Not found") inside the loop prints 'Not found' once for every item that doesn't match.
  • Example:Linear search fills: for count = 0 to theTeam.length - 1; if theTeam[count] == studentName then return True. Use the COUNTER as the array INDEX.

Code examples

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
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
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
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

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 12

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

© 2026 Revise Computing · revisecomputing.co.uk

Privacy noticeTermsContact

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