-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday60.py
More file actions
28 lines (22 loc) · 826 Bytes
/
day60.py
File metadata and controls
28 lines (22 loc) · 826 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Create a class representing a simple bank account with deposit and withdraw methods
class BankAccount:
def __init__(self, balance):
self.balance = balance
def get_balance(self):
print(f"Balance: {self.balance}")
def deposit(self):
amount = float(input("Enter amount to deposit: "))
self.balance += amount
print(f"Deposited: {amount}")
self.get_balance()
def withdraw(self):
amount = float(input("Enter amount to withdraw: "))
if amount <= self.balance:
self.balance -= amount
print(f"Withdrew: {amount}")
self.get_balance()
else:
print("Insufficient funds")
new_account = BankAccount(float(input("Enter bank account balance: ")))
new_account.deposit()
new_account.withdraw()