-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBanking..py
More file actions
87 lines (68 loc) · 2.51 KB
/
Copy pathBanking..py
File metadata and controls
87 lines (68 loc) · 2.51 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
class Banking:
def __init__(self, name, bank_name, pin ):
self.name = name
self.bank_name = bank_name
self.pin = pin
self.balance = 0
self.amount = 0
def money_deposit(self):
print("Enter your amount to be deposited:")
balance = int(input())
if balance <= 0:
print(" Invalid amount enterred for deposition .")
return False
else:
self.balance += balance
print(f" Money deposited to the bank of ₹{balance}. New balance: ₹{self.balance}")
return True
def get_balance(self):
print(f" Current balance: ₹{self.balance}")
return self.balance
def get_summary(self):
print("Card Summary:")
print(f"Holder Name : {self.name}")
print(f"Bank Name : {self.bank_name}")
print(f"Card Number : **** **** **** {self.pin[-4:]}")
print(f"Current Balance: ₹{self.balance}")
def make_payment( self ):
while True:
print("Enter payment amount (or -1 to exit):")
amount = int(input())
if amount == -1:
print(" Exiting payment loop.")
break
elif amount <= 0:
print(" INVALID AMOUNT.")
elif amount > self.balance:
print(" Payment exceeds balance.")
elif self.balance - amount <= 0.1 * self.balance:
print(" Warning: You are near your credit limit!")
self.balance -= amount
print(f" Payment of ₹{amount} received. New balance: ₹{self.balance}")
print("Transaction Successful")
else:
self.balance -= amount
print(f" Payment of ₹{amount} received. New balance: ₹{self.balance}")
print("Transaction Successful")
card = Banking("Ishan", "CodeBank", "4444 9999 6666")
while True:
print("\n What would you like to do?")
print("1. Deposit Money")
print("2. Make a Payment")
print("3. View Balance")
print("4. View Card Summary")
print("5. Exit")
choice = input("Enter your choice (1-5): ")
if choice == '1':
card.money_deposit()
elif choice == '2':
card.make_payment()
elif choice == '3':
card.get_balance()
elif choice == '4':
card.get_summary()
elif choice == '5':
print("👋 Exiting. Thank you!")
break
else:
print("❌ INVALID CHOICE. Please enter a number from 1 to 5.")