0% found this document useful (0 votes)
950 views8 pages

Atm Python Code

The document describes a program for an automatic teller machine (ATM). It imports necessary modules and defines lists to store user accounts including usernames, pins, and balances. It uses while loops to check login details and allow transactions. If an incorrect pin is entered more than 3 times, the program exits for security. After validating login, it displays a menu to view balances, withdraw, deposit, change pin, or quit. Based on the user's selection, it performs the corresponding transaction and updates account details.

Uploaded by

Romil Talaich
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
950 views8 pages

Atm Python Code

The document describes a program for an automatic teller machine (ATM). It imports necessary modules and defines lists to store user accounts including usernames, pins, and balances. It uses while loops to check login details and allow transactions. If an incorrect pin is entered more than 3 times, the program exits for security. After validating login, it displays a menu to view balances, withdraw, deposit, change pin, or quit. Based on the user's selection, it performs the corresponding transaction and updates account details.

Uploaded by

Romil Talaich
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 8

#PROGRAM OF AUTOMATIC TRANSECTION MACHINE (ATM)

#for the program we have to import some modules.

import getpass #warning module

import string

import os

# creating a lists of users, their PINs and bank statements.

users = ["romil", "mudit", "tushar"]

pins = ["6450", "4194", "1999"]

amounts = [500000, 100000, 100000]

count = 0

# while loop checks existance of the enterd username.

while True:

user = input("\nENTER USER NAME: ")

user = user.lower()

#^The user name required is in lower case letters.

if user in users:

#Checking the existance to users in the bank.

if user == users[0]:

n=0

#for name of user according to index position of the list users,

#Here at the 0th index there is ROMIL int he list users.

elif user == users[1]:

n=1

#n=1 is for second user i.e. at the 1st index of list users (MUDIT).

else:

#esle condition for the last user.


#since here are only 3 user thats why n=2 i.e. at second index of list users the element
named is TUSHAR.

n=2

break

else:

#If the required username is not present is not inputed then this esle condition is exectued.

print("----------------")

print("|INVALID USERNAME|")

print("----------------")

# comparing pin

while count < 3:

#the loop will terminate beyond 3 since of only 3 users.

print("|------------------|")

pin = str(getpass.getpass("|PLEASE ENTER PIN|: "))

#to enter the pin

'''"getpass is the waring module, it just convert the statement into waring

i.e. in red letters.For example: We have written "enter pin" then it

would be printed as warning and in red letters.'''

print("|------------------|")

if pin.isdigit():

if user == "romil":

#checking for a pirticular user named romil

if pin == pins[0]:

'''If the pn @ 0th index matches the enetred pin then then

condition comes out to be true and the loop breaks.'''


break

else:

#And if the entered pin not matches with the users pin then this condition get
executed.

count += 1

print("|-----------|")

print("|INVALID PIN|")

print("|-----------|")

print()

if user == "mudit":

#checking for a pirticular user named mudit.

if pin == pins[1]:

'''If the pn @ 1st index matches the enetred pin then then

condition comes out to be true and the loop breaks.'''

break

else:

#And if the entered pin not matches with the users pin then this condition get
executed.

count += 1

print("|-----------|")

print("|INVALID PIN|")

print("|-----------|")

print()

if user == "tushar":

#checking for a pirticular user named tushar.

if pin == pins[2]:
'''If the pn @ 1st index matches the enetred pin then then

condition comes out to be true and the loop breaks.'''

break

else:

#And if the entered pin not matches with the users pin then this condition get
executed.

count += 1

print("|-----------|")

print("|INVALID PIN|")

print("|-----------|")

print()

else:

print("|------------------------|")

print("|PIN CONSISTS OF 4 DIGITS|")

print("|------------------------|")

count += 1

#In case the user input more the 4 digit of pin.

# in case of a valid pin- continuing, or exiting

if count == 3:

#pervent the unauthorised user ot access the pirticular account.

print("|-----------------------------------|")

print("|||3 UNSUCCESFUL PIN ATTEMPTS, EXITING|||")

print("|!!!!!YOUR CARD HAS BEEN LOCKED!!!!!|")

print("|-----------------------------------|")

exit()
#IF the worng pin ie entered more than 3 times the this program will terminate and it automatically
kills the program.

#and if all the entered details are correct then the following codes will get executed..

print("|-----------------------------|")

print("| |/\|ACCESS GARNTED|/\| |")

print("|-----------------------------|")

print(" ||LOGGED IN SUCESSFUYLL|| ")

print("|-----------------------------|")

print("|_____________________________|")

print(str.capitalize(users[n]), "~Welcome to ATM~\n\t [:)(:]")

print("|__________ATM SYSTEM__________|\n\t ~By- RMT~")

# Main menu

while True:

#os.system("clear")

print("|_______________________________|")

response = input("|SELECT FROM FOLLOWING OPTIONS|: \n|Statement--(S)|


\n|Withdraw--(W)| \n|Lodgement--(L)| \n|Change PIN_(P)| \n||Quit--(Q)|| \n: ").lower()

#To display all the related options.

print("|-------------------------------|")

valid_responses = ["s", "w", "l", "p", "q"]#List of all the valid responses.

response = response.lower()

#to convert the letters to lower case iff entered in upper case.

if response == "s":

print("|---------------------------------------------|")

print(str.capitalize(users[n]), "|YOU HAVE ", amounts[n],"RUPEES ON YOUR


ACCOUNT.|")

print("|---------------------------------------------|")
elif response == "w":

cash_out = int(input("|ENTER AMOUNT OF RUPEES YOU WOULD LIKE TO


WITHDRAW|: "))

print("|---------------------------------------------|")

if cash_out%10 != 0:

print("|AMOUNT YOU WANT TO WITHDRAW MUST TO MATCH 100 RUPEES


NOTES|")

print("|------------------------------------------------------|")

elif cash_out > amounts[n]:

print("| ====================== |")

print("|YOU HAVE INSUFFICIENT BALANCE|")

print("| ====================== |")

else:

amounts[n] = amounts[n] - cash_out

print("|YOUR NEW BALANCE IS: ", amounts[n], "RUPEES|")

print("|----------------------------------------------------|")

elif response == "l":

print

cash_in = int(input("|ENTER AMOUNT YOU WANT TO LODGE|: "))

print("|---------------------------------------------|")
if cash_in%10 != 0:

print("|AMOUNT YOU WANT TO LODGE MUST TO MATCH 100 RUPEES


NOTES|")

print("|----------------------------------------------------|")

else:

amounts[n] = amounts[n] + cash_in

print("|YOUR NEW BALANCE IS: ", amounts[n], "RPUEES|")

print("")

print("|----------------------------------------|")

elif response == "p":

print("|-----------------------------|")

print("")

new_pin = str(getpass.getpass("|ENTER A NEW PIN|: "))

print("")

print("|-----------------------------|")

if new_pin.isdigit() and new_pin != pins[n] and len(new_pin) == 4:

print("|------------------|")

print("")

new_ppin = str(getpass.getpass("|CONFIRM NEW PIN|: "))

print("")

print("|-------------------|")

if new_ppin != new_pin:

print("|-----------------|")

print("~~~~~~~~~~~~~~~~~~~")

print("|PIN MISMATCHED!!!|")
print("~~~~~~~~~~~~~~~~~~~")

print("|-----------------|")

else:

pins[n] = new_pin

print("|NEW PIN SAVED|")

else:

print("|-------------------------------------|")

print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")

print(" |NEW PIN MUST CONSIST OF 4 DIGITS \nAND MUST BE DIFFERENT


TO PREVIOUS PIN|")

print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")

elif response == "q":

exit()

else:

print("|------------------|")

print("")

print("|RESPONSE NOT VALID|")

print("")

print("|------------------|")

You might also like