The concept of a bank account in a program makes a good candidate for a class. A bank account typically has the following properties (attributes): the name of the account holder, the account number and the current amount of money in the account. We can execute three actions on a bank account: withdraw money, deposit money and display the particulars of the account. 

Assignment

Your assignment consists of making a class BankAccount with the following methods:

  1. The initializing method __init__ takes the name of the account holder, the account number and an initial amount of money as parameters. The initial amount given is an optional parameter and gets standard value 0.

  2. The method __str__ prints a string representation of a bank account. Use the example below as a base for the format in which your data will be printed.

  3. The method __repr__ also prints a string representation of a bank account. Where the method __str__ is used to obtain a representation of an object that can easily be read for the user, the method __repr__ prints a representation that can only be read by the python interpreter. The method __repr__ gives a syntactical correct Python expression, that — if it were evaluated — creates an object that is equal to the object that was initially given to __repr__.

  4. Two methods deposit(n) and withdraw(n). The parameter of these methods is the amount of money that is withdrawn or deposited.

Example

>>> b1 = BankAccount('Jan Jansen', '001457894501', 10000)
>>> b2 = BankAccount('Peter Peeters', '842457894511', 10000)
>>> b1.deposit(250)
>>> b1.withdraw(1000)
>>> b2.withdraw(300)
>>> str(b1)
'Jan Jansen, 001457894501, amount: 9250'
>>> print(b2)
Peter Peeters, 842457894511, amount: 9700
>>> repr(b2)
"BankAccount('Peter Peeters', '842457894511', 9700)"
>>> b3 = BankAccount('David Davidse', '002457896312')
>>> b3.deposit(112)
>>> print(b3)
David Davidse, 002457896312, amount: 112
>>> b3
BankAccount('David Davidse', '002457896312', 112)