from time import ctime class AccountP: def __init__(self, name, account_number, initial_amount): self._name = name self._no = account_number #self._balance = initial_amount self._transactions = [{'time':ctime(),'amount':initial_amount}] def deposit(self, amount): #self._balance += amount self._transactions.append({'time':ctime(),'amount':amount}) def withdraw(self, amount): #self._balance -= amount self._transactions.append({'time':ctime(),'amount':-amount}) def get_balance(self): s = 0 for tran in self._transactions: s += tran['amount'] return s def dump(self): s = '%s, %s, balance: %s' % \ (self._name, self._no, self.get_balance()) print(s) def print_transactions(self): for tran in self._transactions: s = '%s %g' %(tran['time'], tran['amount']) print(s) a = AccountP('js',1234,100) a.deposit(50) a.deposit(30) a.deposit(40) a.withdraw(10) a.print_transactions() print(a.get_balance()) """ Terminal> python Account3.py Thu Nov 3 06:51:44 2016 100 Thu Nov 3 06:51:44 2016 50 Thu Nov 3 06:51:44 2016 30 Thu Nov 3 06:51:44 2016 40 Thu Nov 3 06:51:44 2016 -10 210 """