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):.
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.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
def deposit(self, amount):Fill in the Blanks
Spot the Error
Student with a class code? Join your class →