← ACARA Digital Technologies Years 9–10

Creating several objects from one class

Creates a second object from the same class. Each object keeps its own attribute values, so changing s2 does not change s1, but both use the same methods.

Understanding Creating several objects from one class in ACARA Digital Technologies Years 9–10

What it does: Both objects come from Student, but each is given a different name, so each stores different data. You make objects by calling the class name with brackets. Writing class again would define a new class, not create an object. Each object stores its own attribute values. Changing s2 does not touch s1. add_points() changed self.score for p1 only. p2 has its own score attribute, which is still 0. Student('Liam') builds a new object. s2 = s1 only gives the same object a second variable name, so no new object is made. self is the object the method was called on. That is why s1.greet() and s2.greet() can print different names.

Common mistakes: == compares values, so no attribute is stored. It should be self.name = name so every Student object keeps its own name. The string is missing its closing quote. It should be print('Woof!'). Both Dog objects share this same bark method.

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
After s1 = Student('Ava') and s2 = Student('Liam'), how many Student objects exist?
Two separate objects, made from one classOne object that both s1 and s2 share
Matches
s1 = Student('Ava') s2 = s1
↓
s2 = s1 does not create a new object. It gives the same object a second name, so changing s2 also changes s1. Fix: s2 = Student('Liam').
Applying
Meanings
Term
s2 = Student('Liam')
Meaning
Creates a second object from the same class. Each object keeps its own attribute values, so changing s2 does not change s1, but both use the same methods.
Practice
class Student:
Testing
Gaps
s2 = ('Liam')
Check Answer
Spots
2 def __init__(self, name):
3 self.name == name

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. After s1 = Student('Ava') and s2 = Student('Liam'), how many Student objects exist?
A. Two separate objects, made from one class ✓
B. One object that both s1 and s2 share
Each time you call Student(...) Python builds a brand new object. s1 and s2 are two different objects from the same class.
2. Which code creates two objects from the same Dog class?
A. class d1(Dog) class d2(Dog)
B. d1 = Dog('Rex') d2 = Dog('Bella') ✓
You make objects by calling the class name with brackets. Writing class again would define a new class, not create an object.
3. s1.name is 'Ava' and s2.name is 'Liam'. You run s2.name = 'Zoe'. What is s1.name now?
A. 'Ava' - it did not change ✓
B. 'Zoe' - both objects changed
Each object stores its own attribute values. Changing s2 does not touch s1.
4. Two Player objects both have an add_points() method. Where is that method defined?
A. Once in the class, shared by both objects ✓
B. Separately inside each object, written twice
Methods are written once in the class. Every object made from it can use them, but each works on its own data.
5. p1 = Player('Mia') and p2 = Player('Noah'), both starting with score 0. After p1.add_points(10), what is p2.score?
A. 10
B. 0 ✓
add_points() changed self.score for p1 only. p2 has its own score attribute, which is still 0.

Match the Pairs

s2 = Student('Liam') → Creates a second object from the Student class with its own separate name value
s1.name = 'Zoe' → Changes the name of s1 only, so s2 keeps its old name
Two objects from the same class can hold different data in their attributes → s1 = Student('Ava') s2 = Student('Liam')
Objects from one class share the same methods but give different results because their data differs → s1.greet() s2.greet()
s1 = Student('Ava') s2 = s1 → s2 = s1 does not create a new object. It gives the same object a second name, so changing s2 also changes s1. Fix: s2 = Student('Liam').
Student.name = 'Zoe' → Using the class name changes the attribute on the class, not on one object. To change only one student use the object name, like s1.name = 'Zoe'.

Key Term

s2 = Student('Liam')
Creates a second object from the same class. Each object keeps its own attribute values, so changing s2 does not change s1, but both use the same methods.

Fill in the Blanks

1. s1 = Student('Ava') s2 = Student('Liam')
Hint: Type the class name used to build the second object.
2. s1 = Student('Ava') s2 = Student('Liam') print(s2.name) # Liam
Hint: Type the variable for the object whose name is Liam.
3. s1 = Student('Ava') s2 = Student('Liam') s2.points = 5 # s1 is unchanged
Hint: Type the object variable that should get the new points, leaving the other object alone.
4. s1.greet() # Hi, I am Ava s2.greet() # Hi, I am Liam
Hint: Type the method name that both objects share.
5. class Student: def __init__(self, name): self.name = name
Hint: Type the special method that sets up each new object's own attribute values.

Spot the Error

Question 1
A class Student:
B def __init__(self, name):
C self.name == name
D s1 = Student('Ava')
E s2 = Student('Liam')
Line C — == compares values, so no attribute is stored. It should be self.name = name so every Student object keeps its own name.
Question 2
A class Dog:
B def bark(self):
C print('Woof!)
D d1 = Dog()
E d2 = Dog()
F d2.bark()
Line C — The string is missing its closing quote. It should be print('Woof!'). Both Dog objects share this same bark method.
Question 3
A class Car:
B def __init__(self, colour):
C self.colour = colour
D car1 = car('red')
E car2 = Car('blue')
Line D — The class name is Car with a capital C, and Python is case sensitive. car is not defined, so it should be car1 = Car('red').
Question 4
A Class Pet:
B def __init__(self, name):
C self.name = name
D p1 = Pet('Milo')
E p2 = Pet('Zara')
Line A — The keyword must be lowercase class. Without it you cannot create p1 and p2 from one Pet blueprint.
Question 5
A class Player
B def __init__(self, score):
C self.score = score
D a = Player(0)
E b = Player(0)
Line A — A class header must end with a colon. It should be class Player: so that a and b can both be created from it.

Student with a class code? Join your class →