Basic deposit and balance retrieval
Input
acct = BankAccount('Alice', 100, '1234') acct.deposit(50) acct.balance
Output
150
deposit(50) increases balance to 150 and balance property returns the new balance (150).
Full lesson preview
Implement a BankAccount class that demonstrates encapsulation: private attributes, read-only properties, validated setters and controlled write operations.
Problem statement
Task
Examples
Input
acct = BankAccount('Alice', 100, '1234') acct.deposit(50) acct.balance
Output
150
deposit(50) increases balance to 150 and balance property returns the new balance (150).
Input format
Output format
Constraints
Samples
Input
acct = BankAccount('Bob', 200, '0000', overdraft_limit=50) acct.withdraw(230, '0000') acct.balance
Output
-30
Withdraw 230 from 200 with 50 overdraft allowed leaves -30.