-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbanking_slot.py
More file actions
64 lines (44 loc) · 1.34 KB
/
Copy pathbanking_slot.py
File metadata and controls
64 lines (44 loc) · 1.34 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
# python banking program
def show_balance(balance):
print(f"Your balance is ${balance:.2f}")
def deposit():
amount = float(input("Enter your amount sir:"))
if amount < 0:
print("amount must be greater than 0")
return 0
else:
return amount
def withdraw(balance):
amount = float(input("enter your amount sir:"))
if amount > balance:
print("insufficient funds")
return 0
elif amount < 0:
print("amount must be greater than 0")
return 0
else:
return amount
def main():
balance = 0
is_running = True
while is_running:
print("*******")
print("BANKING PROGRAM WELCOMES YOU")
print("*******")
print("1.show_balance")
print("2.deposit")
print("3.withdraw")
print("4.exit")
choice = input("enter your choice (1-4): ")
if choice == '1' :
show_balance(balance)
elif choice == '2' :
balance += deposit()
elif choice == '3' :
balance -= withdraw(balance)
elif choice == '4' :
is_running = False
else :
print("this is invalid choice")
print("Thank you have a nice day")
main()