A banking app has two kinds of account. They share almost everything, so write the shared part once.
Account(owner, balance) (the parent):
deposit(amount) adds amount to the balance and returns the new balance.withdraw(amount) takes amount out, but only if there's enough. If amount is bigger than the balance, nothing changes. Either way, it returns the balance.Savings (a child of Account):
interest() returns 3% of the balance, rounded to 2 decimal places.Wallet (a child of Account):
is_empty() returns True if the balance is exactly 0, otherwise False.Neither child needs an __init__ of its own.
Then write two functions:
savings_interest(owner, deposits): make a Savings with a balance of 0, deposit each amount in the list in order, and return interest().wallet_check(owner, start, spends): make a Wallet with balance start, try to withdraw each amount in order (too-big ones are skipped), and return [balance, is_empty()].