-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
67 lines (54 loc) · 1.64 KB
/
main.py
File metadata and controls
67 lines (54 loc) · 1.64 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
# Python Banking Program
def show_balance(balance):
print("*******************")
print(f"Your balance is ${balance:.2f}")
print("*******************")
def deposit():
amount = float(input("Enter an amount to be deposited: "))
if amount < 0:
print("*******************")
print("That's not a valid amount")
print("*******************")
return 0
else:
return amount
def withdraw(balance):
amount = float(input("Enter amount to be withdrawn: "))
if amount > balance:
print("*******************")
print("Insufficient funds")
print("*******************")
elif amount < 0:
print("*******************")
print("Amount must be more than 0")
print("*******************")
else:
return amount
def main():
balance = 0
is_running = True
while is_running:
print("********************")
print("Banking Program")
print("********************")
print("1.Show Balance")
print("2.Deposit")
print("3.Withdraw")
print("4.Exit")
print("*******************")
choice = input("Enter you 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("*******************")
print("That is not a valid choice")
print("*******************")
print("Thank you! Have a nice day.")
if __name__ == '__main__':
main()