""" Ex. 7.3 from "A primer on...". Modify the AccountP class to remove the _balance attribute and replace it with a list of transactions. Usage of the original class methods should remain the same. Also add one method which prints all transactions. """ from datetime import datetime class BankAccountP: def __init__(self, first_name, last_name, number, balance): self._first_name = first_name self._last_name = last_name self._number = number trans = {'time': datetime.now(), 'amount': balance} self._transactions = [trans] def deposit(self, amount): trans = {'time': datetime.now(), 'amount': amount} self._transactions.append(trans) #self._balance += amount def withdraw(self, amount): self.deposit(-amount) #self._balance -= amount def get_balance(self): balance = 0 for t in self._transactions: balance += t['amount'] return balance def print_info(self): first = self._first_name; last = self._last_name number = self._number; bal = self.get_balance() s = f'{first} {last}, {number}, balance: {bal}' print(s) def print_transactions(self): for t in self._transactions: print(f"Time: {t['time']}, amount: {t['amount']}") a1 = BankAccountP('John', 'Olsson', '19371554951', 20000) a2 = BankAccountP('Liz', 'Olsson', '19371564761', 20000) a1.deposit(1000) a1.withdraw(4000) a2.withdraw(10500) a1.withdraw(3500) print("a1's balance:", a1.get_balance()) a1.print_info() a1.print_transactions() """ Terminal> python account3.py a1's balance: 13500 John Olsson, 19371554951, balance: 13500 Time: 2023-10-24 17:42:20.057255, amount: 20000 Time: 2023-10-24 17:42:20.057264, amount: 1000 Time: 2023-10-24 17:42:20.057266, amount: -4000 Time: 2023-10-24 17:42:20.057268, amount: -3500 """