Apply your OOP skills to model a real-world bank account. Use a class with attributes and methods to handle deposits, withdrawals, and balance checks.
YOUR TASK
Create a BankAccount class that:
Has an __init__ method with owner and balance
Has a deposit(amount) method
Has a withdraw(amount) method (reject if insufficient funds)
Has a get_balance() method that prints the balance
Need a hint?
Class structure: class BankAccount: def __init__(self, owner, balance=0): self.owner = owner self.balance = balance
Then add deposit, withdraw, and get_balance methods using self.balance.
Example output:
Balance: 1000
Balance: 1500
Balance: 1200
Code Editor
Ready
Output
Console
Console initialized...
Ready for Project 2: Bank Account System
> Test your code with "Check My Code"
> Complete button activates when your class works!