← ACARA Digital Technologies Years 9–10

Methods with parameters and return values (Python)

A method can take extra parameters after self, like amount, and use return to send a value back to the code that called it.

Understanding Methods with parameters and return values (Python) in ACARA Digital Technologies Years 9–10

What it does: The parameter amount is added to the balance attribute through self, so the deposit changes the object's stored data. The if test only lets the attribute change when the amount is valid, which stops bad values like negative deposits. Python automatically passes the object as self. You only supply the extra arguments. return sends the value back so it can be stored in a variable. print only shows it on screen. You need brackets to call the method. Without them you just get the method itself, not its returned value. The check must come first. Otherwise the balance has already changed before the test happens.

Common mistakes: This line only calculates a value and throws it away, so the attribute never changes. Use += (self.balance += amount) to update the balance. Every method must list self as its first parameter before any extra parameters. It should be def deposit(self, amount):.

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
Which method header correctly takes an amount to deposit?
def deposit(amount, self):def deposit(self, amount):
Matches
def deposit(amount): self.balance += amount
↓
The method is missing self as its first parameter, so it cannot access self.balance and the call will fail with a TypeError.
Applying
Meanings
Term
def deposit(self, amount):
Meaning
A method can take extra parameters after self, like amount, and use return to send a value back to the code that called it.
Practice
class Account:
Testing
Gaps
def deposit(self, ):
Check Answer
Spots
2 def deposit(self, amount):
3 self.balance + amount

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

The 'Space Turtle' badge — Speed in Zero-G, 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. Which method header correctly takes an amount to deposit?
A. def deposit(self, amount): ✓
B. def deposit(amount, self):
self must always be the first parameter. Extra parameters like amount come after it.
2. A BankAccount has self.balance = 100. What does account.deposit(50) do if deposit is def deposit(self, amount): self.balance += amount?
A. balance becomes 150 ✓
B. balance stays 100
The value 50 is passed into amount, and += adds it to self.balance, so the attribute changes.
3. When you call account.deposit(50), how many arguments do you write inside the brackets?
A. Two: account and 50
B. One: 50 (Python passes self for you) ✓
Python automatically passes the object as self. You only supply the extra arguments.
4. Which method sends a calculated value back to the code that called it?
A. def get_double(self): return self.balance * 2 ✓
B. def get_double(self): print(self.balance * 2)
return sends the value back so it can be stored in a variable. print only shows it on screen.
5. Given def get_total(self): return self.price * self.qty, which line stores the result?
A. total = item.get_total
B. total = item.get_total() ✓
You need brackets to call the method. Without them you just get the method itself, not its returned value.

Match the Pairs

def deposit(self, amount): → A method that takes an extra parameter, amount, after self so the caller can pass in a value to use
return self.balance * 0.05 → Sends a calculated value back to the code that called the method
A method changes an attribute using the value passed in as a parameter → self.balance += amount
A method checks a value with an if statement before it changes an attribute → if amount > 0: self.balance += amount
def deposit(amount): self.balance += amount → The method is missing self as its first parameter, so it cannot access self.balance and the call will fail with a TypeError.
def get_interest(self): print(self.balance * 0.05) → The method uses print instead of return, so it only displays the value and the caller gets None back.

Key Term

def deposit(self, amount):
A method can take extra parameters after self, like amount, and use return to send a value back to the code that called it.

Fill in the Blanks

1. def deposit(self, amount): self.balance += amount
Hint: Type the name of the extra parameter that receives the money being added.
2. def deposit(self, amount): self.balance += amount
Hint: Type the operator that adds the amount to the existing balance.
3. def area(self): return self.width * self.height
Hint: Type the keyword that sends the calculated value back to the caller.
4. def withdraw(self, amount): if amount <= self.balance: self.balance -= amount
Hint: Type the comparison operator that checks there is enough money before changing the balance.
5. acc = Account(100) acc.deposit(50) print(acc.balance)
Hint: Type the method name that is called on the object with 50 as its argument.

Spot the Error

Question 1
A class Account:
B def deposit(self, amount):
C self.balance + amount
D return self.balance
Line C — This line only calculates a value and throws it away, so the attribute never changes. Use += (self.balance += amount) to update the balance.
Question 2
A class Account:
B def deposit(amount):
C self.balance += amount
Line B — Every method must list self as its first parameter before any extra parameters. It should be def deposit(self, amount):
Question 3
A class Wallet:
B def spend(self, amount)
C self.cash -= amount
D return self.cash
Line B — A method definition must end with a colon. It should be def spend(self, amount):
Question 4
A class Account:
B def withdraw(self, amount):
C if amount = self.bal:
D self.bal -= amount
Line C — A single = assigns a value, but a condition needs a comparison. To check the amount is not more than the balance, use if amount <= self.bal:
Question 5
A class Item:
B def total(self, qty):
C sub = self.price * qty
D print(sub)
Line D — print() only shows the value on screen and the method returns None. To send the value back to the caller, use return sub.

Student with a class code? Join your class →