forked from blksail-edu/python-refresher
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbank.py
More file actions
22 lines (19 loc) · 748 Bytes
/
bank.py
File metadata and controls
22 lines (19 loc) · 748 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
class Bank:
def __init__(self, name: str, account_number: int, balance: float or int = 0):
self.balance = balance
self.name = name
self.account_number = account_number
def withdraw(self, money: int or float):
if self.balance <= money:
raise ValueError("Not enough money to withdraw.")
else:
self.balance -= money
print(f"Successfully withdrew {money} from account.")
return self.balance
def deposit(self, money: int or float):
self.balance += money
print(f"Successfully deposited {money} in account.")
return self.balance
def print_balance(self):
print(f"Balance: {self.balance}")
return self.balance