-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquestion10.py
More file actions
41 lines (33 loc) · 1.28 KB
/
question10.py
File metadata and controls
41 lines (33 loc) · 1.28 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
def question10():
balence = 1000
while True:
print("\n=== ATM MACHINE ===")
print("1. Check Balance")
print("2. Deposit")
print("3. Withdraw")
print("4. Exit")
choice = int(input("Choose an option (1-4): "))
if choice == 4:
print("Exiting program...")
break
elif choice == 1:
print(f"Your current balance is: ${balence:.2f}")
elif choice == 2:
amount = float(input("Enter amount to deposit: "))
if amount > 0:
balence += amount
print(f"Deposited ${amount:.2f}. New balance: ${balence:.2f}")
else:
print("Invalid amount. Please enter a positive number.")
elif choice == 3:
amount = float(input("Enter amount to withdraw: "))
if amount > balence:
print("Insufficient funds.")
elif amount <= 0:
print("Invalid amount. Please enter a positive number.")
else:
balence -= amount
print(f"Withdrew ${amount:.2f}. New balance: ${balence:.2f}")
else:
print("Invalid choice. Please select a number between 1 and 4.")
question10()