Revise Computingrevisecomputing.co.uk
At a glanceFeaturesStudentsPricingHow it worksFree GCSE notesExam dates
At a glanceFeaturesStudentsPricingHow it worksFree GCSE notesExam dates

Knowledge organisers / Arrays and Records

Arrays in subprograms

All topicsPractise exam questions
Knowledge organiser

Arrays and Records

301.17c

Pass list to functions.

What you need to know

You can pass a list to a function as a parameter. Functions can read, modify, or return new lists. Changes to the list inside the function affect the original.

Key points

  • Pass a list like any other parameter
  • The function receives a reference — changes affect the original
  • Return a new list if you don't want to modify the original
  • Common pattern: function takes a list and returns a result

Code examples

List as parameter
python
def find_highest(scores):
    highest = scores[0]
    for s in scores:
        if s > highest:
            highest = s
    return highest

marks = [72, 85, 91, 68]
print(find_highest(marks))  # 91