- 18 Haz 2022
- 168
- 1
- 33
Merhabalar python öğrenmeye yeni başladım (2 ay oldu ) dün can sıkıntısından birşey yapayım dedim ve aklıma ATM sistemi geldi bu sistemi sizinle paylaşmak istedim
Python:
# python 3.7.1
balance = 1000
def login():
username = input("Enter your username: ")
password = input("Enter your password: ")
if username == "admin" and password == "admin":
print("\nLogin successful!")
return True
else:
print("Incorrect username or password.")
return False
def main_menu():
print("\nWelcome to the ATM!")
print("1. Check Balance")
print("2. Withdraw")
print("3. Deposit")
print("4. Exit")
choice = input("Enter your choice: ")
return choice
def check_balance():
print("Your current balance is: $", balance)
def withdraw():
global balance
amount = int(input("Enter the amount to withdraw: "))
if amount > balance:
print("Insufficient balance!")
else:
balance -= amount
print("Withdrawal successful! Your new balance is: $", balance)
def deposit():
global balance
amount = int(input("Enter the amount to deposit: "))
balance += amount
print("Deposit successful! Your new balance is: $", balance)
while not login():
continue
while True:
choice = main_menu()
if choice == "1":
check_balance()
elif choice == "2":
withdraw()
elif choice == "3":
deposit()
elif choice == "4":
print("Thank you for using the ATM!")
break
else:
print("Invalid choice. Please try again.")