Methods are functions defined inside a class. They always take self as the first parameter.
class BankAccount:
def __init__(self, balance):
self.balance = balance
def deposit(self, amount):
self.balance += amount
def get_balance(self):
return self.balanceaccount = BankAccount(100)
account.deposit(50)
print(account.get_balance()) # 150
Add a method apply_tax to the Expense class that:
tax_rate parameter (decimal, e.g., 0.08)Run your code to see output