phatboislym

atm.py

Aug 4th, 2023
1,147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.23 KB | Source Code | 0 0
  1. from time import sleep
  2.  
  3. balance = 2500
  4. withdrawal = {1: 1000, 2: 2000, 3: 5000, 4: 10000, 5: 20000}
  5.  
  6.  
  7. def dispense(amount: int):
  8.     balance = 2500
  9.     withdrawal = {1: 1000, 2: 2000, 3: 5000, 4: 10000, 5: 20000}
  10.     if balance >= withdrawal[amount]:
  11.         print(f"paying =N={withdrawal[amount]}")
  12.         balance -= withdrawal[amount]
  13.     else:
  14.         print("insufficient funds")
  15.  
  16.  
  17. print("Welcome to GTBank!")
  18. sleep(3)
  19.  
  20. response = int(input(
  21.     "press 0 for cardless transactions\npress 1 for card transactions\n"))
  22. if response == 0:
  23.     print("cardless transactions")
  24. elif response == 1:
  25.     operation = int(input(
  26.         "please select a transaction\n1: account balance\n2: cash withdrawal\n3: airtime topup\n"))
  27.     if operation == 1:
  28.         print(f"your account balance is =N={balance}")
  29.     elif operation == 2:
  30.         amount = int(input(
  31.             "please select withdrawal amount\n1: =N=1000\n2: =N=2000\n3: =N=5000\n4: =N=10000\n5: =N=20000\n6: enter amount\n"))
  32.         if amount == 1:
  33.             dispense(amount)
  34.         elif amount == 2:
  35.             dispense(amount)
  36.         elif amount == 3:
  37.             dispense(amount)
  38.         elif amount == 4:
  39.             dispense(amount)
  40.         elif amount == 5:
  41.             dispense(amount)
  42.         elif amount == 6:
  43.             specific_amount = int(
  44.                 input("enter amount\namount should be a multiple of =N=1000\n"))
  45.             if specific_amount % 1000:
  46.                 print("amount must be a multiple of =N=1000")
  47.             elif specific_amount > 20000:
  48.                 print("amount must not be more than =N=20000")
  49.             else:
  50.                 if balance >= specific_amount:
  51.                     print(f"paying =N={specific_amount}")
  52.                     balance -= specific_amount
  53.                 else:
  54.                     print("insufficient funds")
  55.         else:
  56.             print("invalid selection")
  57.     elif operation == 3:
  58.         airtime = int(input("enter recharge amount\n"))
  59.         if airtime <= balance:
  60.             print(f"recharged {airtime} naira")
  61.             balance -= airtime
  62.         else:
  63.             print("insufficient funds")
  64.     else:
  65.         print("invalid selection")
  66. else:
  67.     print("invalid selection")
  68.  
  69. sleep(3)
  70. print("thank for banking with us")
  71.  
Advertisement
Add Comment
Please, Sign In to add comment