-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBankingProgram.py
More file actions
51 lines (47 loc) · 1.46 KB
/
BankingProgram.py
File metadata and controls
51 lines (47 loc) · 1.46 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
# python banking program
def balance():
print("total amount is $", amount)
def deposit():
global amount
credit = int(input("enter the deposit amount: "))
while True:
if credit < 0:
print("Invalid amount")
credit = int(input("enter the deposit amount: "))
else:
amount += credit
print(f"{credit} is credited in your account, your total balance is {amount}")
break
def withdraw():
global amount
debit = int(input("enter the withdraw amount: "))
while True:
if debit <= 0:
print("Invalid amount")
debit = int(input("enter the withdraw amount: "))
elif debit > amount:
print("insufficient balance")
debit = int(input("enter the withdraw amount: "))
else:
amount -= debit
print(f"{debit} is debited now, total is {amount}")
break
amount = 0
while True:
print(" 1 to verify the balance: ")
print(" 2 to deposit the amount:")
print(" 3 to withdraw the amount: ")
print(" Q to exit: ")
choose = input("choose the options (1 - 3) or Q to exit: ").upper()
if choose == "Q":
print("EXIT - THANK YOU")
break
elif choose == "1":
balance()
elif choose == "2":
deposit()
elif choose == "3":
withdraw()
else:
print("----INVALID-----")
choose = input("choose the options (1 - 3) or Q to exit: ").upper()