← ACARA Digital Technologies Years 9–10

Why object-oriented programming is used

A way of writing programs that groups related data and the code that uses it into one unit called an object, so programs modelling real things are easier to organise than separate lists and functions.

Understanding Why object-oriented programming is used in ACARA Digital Technologies Years 9–10

What it does: A method inside a class uses self to change the object's own data, so the data and the code that uses it stay together. Parallel lists rely on matching positions. If you remove from one list but forget the others, the data for one person gets mixed up. Objects keep each student's data together. OOP suits programs that model real things. A Player object can hold its own health and score and know how to move or attack. Other styles of programming can still run games. Data (name) and behaviour (bark) are bundled in one unit. Two separate lists hold only data and are not linked.

Common mistakes: Parallel lists only work if the same index is used in both lists. names[1] is Liam but marks[2] is Mia's mark. It should be marks[1]. This easy mistake is one reason parallel lists are risky. Lists have no add() method, so this causes an AttributeError. Use marks.append(95). With parallel lists you must remember to update every list each time, or the data goes out of sync.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 629–680) and word search (Modules 629–707).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
A program stores student data in three parallel lists: names, ages and scores. What is the main risk?
Python cannot store more than one list at a timeThe lists can fall out of step, so index 2 no longer matches one student
Matches
names.remove('Ava') # scores still has Ava's mark
↓
With parallel lists, removing an item from one list leaves the other lists out of step, so names and scores no longer match
Applying
Meanings
Term
object-oriented programming
Meaning
A way of writing programs that groups related data and the code that uses it into one unit called an object, so programs modelling real things are easier to organise than separate lists and functions.
Practice
class Pet:
Testing
Gaps
print(names[0], points[])
Check Answer
Spots
2marks = [88, 65, 95]
3print(names[1], marks[2])

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Peregrine Falcon' badge — Operator Ace, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. A program stores student data in three parallel lists: names, ages and scores. What is the main risk?
A. The lists can fall out of step, so index 2 no longer matches one student ✓
B. Python cannot store more than one list at a time
Parallel lists rely on matching positions. If you remove from one list but forget the others, the data for one person gets mixed up. Objects keep each student's data together.
2. Which statement best describes object-oriented programming?
A. It stores all data in one list and keeps all code in separate functions
B. It groups related data and the code that uses it into one unit called an object ✓
OOP bundles data (attributes) and behaviour (methods) together, so one object can represent one real thing.
3. You are building a game with players, enemies and items. Why is OOP a good fit?
A. OOP is the only way Python can run a game
B. Each real-world thing can be modelled as an object with its own data and actions ✓
OOP suits programs that model real things. A Player object can hold its own health and score and know how to move or attack. Other styles of programming can still run games.
4. A list of dictionaries holds pet data like {'name': 'Rex', 'age': 3}. What is a limit of this approach?
A. The dictionaries hold data only, so the code that uses it lives separately in functions ✓
B. Dictionaries cannot hold a name and an age together
Dictionaries do group data, but the behaviour (like a birthday function) stays outside. An object keeps data and behaviour together.
5. Which one is an example of data and behaviour together?
A. A Dog object with a name attribute and a bark() method ✓
B. A list called dog_names and a separate list called dog_ages
Data (name) and behaviour (bark) are bundled in one unit. Two separate lists hold only data and are not linked.

Match the Pairs

names = ['Ava', 'Liam'] scores = [88, 65] → Parallel lists: related data is split across separate lists, so every list must be kept in the same order by hand
class Student: def __init__(self, name, score): → A class bundles the data (name, score) for one real-world thing into a single unit
Data and behaviour live together: an object holds its own data and has methods that work on that data → def add_points(self, n): self.points += n
Modelling a real-world thing: one object stands for one student, pet or game character → ava = Student('Ava', 88)
names.remove('Ava') # scores still has Ava's mark → With parallel lists, removing an item from one list leaves the other lists out of step, so names and scores no longer match
student = {'name': 'Ava', 'score': 88} student['scroe'] = 90 → A dictionary has no fixed structure or built-in behaviour, so a typo in a key silently creates a new key instead of giving an error

Key Term

object-oriented programming
A way of writing programs that groups related data and the code that uses it into one unit called an object, so programs modelling real things are easier to organise than separate lists and functions.

Fill in the Blanks

1. names = ["Ava", "Liam"] points = [120, 95] print(names[0], points[0])
Hint: Type the index that finds the same student's points in the parallel list
2. students = [{"name": "Ava", "pts": 120}] for s in students: print(s)
Hint: Type the keyword that goes through each dictionary in the list
3. class Student: def show(self): print("Hi")
Hint: Type the keyword that starts a blueprint grouping data and code
4. class Dog: def bark(self): print("Woof")
Hint: Type the keyword that adds behaviour inside a class
5. class Car: pass mine = Car()
Hint: Type the class name used to create an object

Spot the Error

Question 1
A names = ["Ava", "Liam", "Mia"]
B marks = [88, 65, 95]
C print(names[1], marks[2])
Line C — Parallel lists only work if the same index is used in both lists. names[1] is Liam but marks[2] is Mia's mark. It should be marks[1]. This easy mistake is one reason parallel lists are risky.
Question 2
A names = ["Ava", "Liam"]
B marks = [88, 65]
C names.append("Mia")
D marks.add(95)
Line D — Lists have no add() method, so this causes an AttributeError. Use marks.append(95). With parallel lists you must remember to update every list each time, or the data goes out of sync.
Question 3
A p = {"name": "Ava", "age": 15}
B p.age += 1
C print(p["name"], p["age"])
Line B — Dictionary values are reached with square brackets and a key, not dot notation. It should be p["age"] += 1. Dictionaries hold data, but they have no way to bundle behaviour with it.
Question 4
A pupils = [
B {"name": "Ava" "xp": 88},
C {"name": "Liam", "xp": 65}
D ]
Line B — A comma is missing between the key-value pairs "name": "Ava" and "xp": 88, which is a SyntaxError. It should be {"name": "Ava", "xp": 88},. A list of dictionaries stores the data, but nothing checks that every dictionary has the same keys.
Question 5
A Class Pupil:
B def __init__(self, name):
C self.name = name
D def greet(self):
E print("Hi", self.name)
Line A — The class keyword must be lowercase. It should be class Pupil:. A class groups data (name) and behaviour (greet) into one unit.

Student with a class code? Join your class →