Bank Account Class
Python
20 pts
Bank Account Class
Create a class BankAccount.
BankAccount(owner, balance=0)storesownerandbalanceas attributes.deposit(amount)addsamountto the balance. Ifamountis 0 or less, raiseValueError.withdraw(amount)subtractsamount. Ifamountis more than the balance, raiseValueErrorand leave the balance unchanged.str(account)returns text like"Selam: 150 Nakfa".
Checklist
- Create the class with
ownerandbalance. - Add
deposit()with its safety check. - Add
withdraw()with its safety check. - Add
__str__().
🔑 Solution
If you view the solution before passing, you earn half points for this exercise. You still need to type it and press Check to finish.
How it works, step by step
Point at a step to highlight its lines. Type the solution yourself and press Check answer to finish.
