From the course: Getting Started with Python Object Oriented Programming: A Hands-On Approach
Unlock the full course today
Join today to access over 24,100 courses taught by industry experts.
Getters - Python Tutorial
From the course: Getting Started with Python Object Oriented Programming: A Hands-On Approach
Getters
- [Instructor] If you look in the repo for the start state of chapter 04_02, you'll find that we have a class here defining a BankAccount. And this BankAccount has three properties. So on lines 3, 4, and 5, we have self.account_number, self.account_holder, and self.balance. These are the properties of the class. And also if you look line two, you'll see that we're passing in some arguments. So when we create an instance of a BankAccount, we pass in the account number, we pass in the account holder, and we have for the balance what is called a default argument. Now, what this does is it means you can enter a value for the balance, but if you don't, the balance will be set by default to zero. Then we create an instance of the class on line 11, passing in the account number of 123456789 and the account holder of Fred Bloggs and a balance of a thousand, whatever the units are. And then we simply print these values out by accessing directly to line 14, for example. You have…