Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from datetime import datetime
- date=datetime.today()
- date=date.strftime('%Y/%B/%d %H:%M:%S %p')
- users={'1111':'user1','2222':'user2','3333':'user3','4444':'user4'}
- user_amt={'1111':1000,'2222':2000,'3333':3000,'4444':4000}
- print('Welcome to Py Bank!')
- trial=0
- while trial<=3:
- pin=input('\nEnter your atm pin:')
- if pin.isdigit()==True and len(pin)==4 and pin in users.keys():
- print('Hello!',users[pin],'\nLog in Successful!')
- break
- else:
- print('Invalid Input.\nTry again.')
- trial+=1
- else:
- print('Four attempts failed.\nThis card has been blocked.')
- exit()
- def get_acct_statement():
- print('\nDear',users[pin],'\nAccount balance as at',date,':','N',user_amt[pin])
- def withdrawal():
- attempt=0
- while attempt<=3:
- amt=int(input("\nEnter amount to withdraw:"))
- if amt<200 or amt>user_amt[pin]:
- print("Withdrawal failed!\nYou can't withdraw lower than N200 or higher than your available balance.\nYour current balance is:N",user_amt[pin])
- attempt+=1
- else:
- print("Withdrawal Successful!\nPlease wait and collect you cash.")
- break
- else:
- print('Four attempts failed.\nTry again later.')
- exit()
- def deposit():
- attempt=0
- while attempt<=3:
- amt=int(input('\nEnter amount to deposit:'))
- if amt<1000 or amt>100000:
- print("Deposit failed!\nYou can't deposit less than N1000 or more than N100000.")
- attempt+=1
- else:
- total=amt+user_amt[pin]
- print('Deposit Successful.\nYour new balance as at:',date,':N',total)
- break
- else:
- print('Four attempts failed.\nTry again later.')
- exit()
- def change_pin():
- attempt=0
- while attempt<=3:
- pin2=input('\nEnter new pin:')
- if pin2.isdigit()==True and len(pin2)==4 and pin2!=pin:
- attempt2=0
- while attempt2<=3:
- pin3=input('Confirm new pin:')
- if pin2==pin3:
- print("You've successfully changed your pin!\nYour new pin is:",pin3)
- break
- else:
- print('Invalid pin.\nTry again.')
- attempt2+=1
- else:
- print('Four attempts failed.\nThis card has been blocked.')
- exit()
- else:
- print('Invalid pin.\nEnsure that new pin is of four digits and not same as old pin.\nTry again.')
- attempt+=1
- else:
- print('Four attempts failed.\nTry again later.')
- exit()
- def operations():
- print('\nSelect any of the options by inputting the appropriate number.')
- print('1.Get Account Statement','\n2.Withdrawal','\n3.Deposit','\n4.Change Pin','\n5.Quit.')
- reply=input('Enter number:')
- if reply=='1':
- get_acct_statement()
- elif reply=='2':
- withdrawal()
- elif reply=='3':
- deposit()
- elif reply=='4':
- change_pin()
- elif reply=='5':
- exit()
- else:
- print('Invalid Input.\nThank you, for using Py Bank!')
- exit()
- while True:
- operations()
- reply=input("\nWould you like to perfom another transaction?\nY or N:").lower()
- if reply=='y':
- continue
- elif reply=='n':
- print('Thank you, for using Py Bank!')
- break
- else:
- print('I do not understand.')
- exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement