-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBank.py
More file actions
54 lines (46 loc) · 1.56 KB
/
Bank.py
File metadata and controls
54 lines (46 loc) · 1.56 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
class BankAccount:
def __init__(self, name):
self.name = name
self.balance = 0.0
def deposit(self, amount):
if amount > 0:
self.balance += amount
print(f"₹{amount} deposited successfully.")
else:
print("Invalid deposit amount.")
def withdraw(self, amount):
if amount > self.balance:
print("Insufficient balance.")
elif amount <= 0:
print("Invalid withdrawal amount.")
else:
self.balance -= amount
print(f"₹{amount} withdrawn successfully.")
def check_balance(self):
print(f"Current balance: ₹{self.balance}")
def main():
print("Welcome to Simple Bank!")
name = input("Enter your name to create an account: ")
account = BankAccount(name)
while True:
print("\nChoose an option:")
print("1. Deposit")
print("2. Withdraw")
print("3. Check Balance")
print("4. Exit")
choice = input("Enter your choice (1-4): ")
if choice == '1':
amount = float(input("Enter amount to deposit: ₹"))
account.deposit(amount)
elif choice == '2':
amount = float(input("Enter amount to withdraw: ₹"))
account.withdraw(amount)
elif choice == '3':
account.check_balance()
elif choice == '4':
print("Thank you for banking with us!")
break
else:
print("Invalid choice. Please try again.")
if __name__ == "__main__":
main()