ATM Management Python Project for Class 12

 

 

#!/usr/bin/python
#cbsepython.in
import getpass
import string
import os

# creating a lists of users, their PINs and bank statements
users = ['jitendra', 'sunny', 'vivek']
pins = ['1111', '2222', '3333']
amounts = [1000, 2000, 3000]
count = 0
# while loop checks existance of the enterd username
while True:
    user = input('\nENTER USER NAME: ')
    print(user)
    user = user.lower()
    if user in users:
        if user == users[0]:
            n = 0
        elif user == users[1]:
            n = 1
        else:
            n = 2
        break
    else:
        print('----------------')
        print('****************')
        print('INVALID USERNAME')
        print('****************')
        print('----------------')

# comparing pin
while count < 3:
    print('------------------')
    print('******************')
    pin = str(input('PLEASE ENTER PIN: '))
    print('******************')
    print('------------------')
    if pin.isdigit():
        if user == users[0]:
            if pin == pins[0]:
                break
            else:
                count += 1
                print('-----------')
                print('***********')
                print('INVALID PIN')
                print('***********')
                print('-----------')
                print()

        if user == users[1]:
            if pin == pins[1]:
                break
            else:
                count += 1
                print('-----------')
                print('***********')
                print('INVALID PIN')
                print('***********')
                print('-----------')
                print()
                
        if user == users[2]:
            if pin == pins[2]:
                break
            else:
                count += 1
                print('-----------')
                print('***********')
                print('INVALID PIN')
                print('***********')
                print('-----------')
                print()
    else:
        print('------------------------')
        print('************************')
        print('PIN CONSISTS OF 4 DIGITS')
        print('************************')
        print('------------------------')
        count += 1
    
# in case of a valid pin- continuing, or exiting
if count == 3:
    print('-----------------------------------')
    print('***********************************')
    print('3 UNSUCCESFUL PIN ATTEMPTS, EXITING')
    print('!!!!!YOUR CARD HAS BEEN LOCKED!!!!!')
    print('***********************************')
    print('-----------------------------------')
    exit()

print('-------------------------')
print('*************************')
print('LOGIN SUCCESFUL, CONTINUE')
print('*************************')
print('-------------------------')
print()
print('--------------------------')
print('**************************')	
print(str.capitalize(users[n]), 'welcome to ATM')
print('**************************')
print('----------ATM SYSTEM-----------')
# Main menu
while True:
    #os.system('clear')
    print('-------------------------------')
    print('*******************************')
    response = input('SELECT FROM FOLLOWING OPTIONS: \nStatement__(S) \nWithdraw___(W) \nLodgement__(L)  \nChange PIN_(P)  \nQuit_______(Q) \n: ').lower()
    print('*******************************')
    print('-------------------------------')
    valid_responses = ['s', 'w', 'l', 'p', 'q']
    response = response.lower()
    if response == 's':
        print('---------------------------------------------')
        print('*********************************************')
        print(str.capitalize(users[n]), 'YOU HAVE ', amounts[n],'RUPEES ON YOUR ACCOUNT.')
        print('*********************************************')
        print('---------------------------------------------')
        
    elif response == 'w':
        print('---------------------------------------------')
        print('*********************************************')
        cash_out = int(input('ENTER AMOUNT YOU WOULD LIKE TO WITHDRAW: '))
        print('*********************************************')
        print('---------------------------------------------')
        if cash_out%10 != 0:
            print('------------------------------------------------------')
            print('******************************************************')
            print('AMOUNT YOU WANT TO WITHDRAW MUST TO MATCH 10 RUPEES NOTES')
            print('******************************************************')
            print('------------------------------------------------------')
        elif cash_out > amounts[n]:
            print('-----------------------------')
            print('*****************************')
            print('YOU HAVE INSUFFICIENT BALANCE')
            print('*****************************')
            print('-----------------------------')
        else:
            amounts[n] = amounts[n] - cash_out
            print('-----------------------------------')
            print('***********************************')
            print('YOUR NEW BALANCE IS: ', amounts[n], 'RUPEES')
            print('***********************************')
            print('-----------------------------------')
            
    elif response == 'l':
        print()
        print('---------------------------------------------')
        print('*********************************************')
        cash_in = int(input('ENTER AMOUNT YOU WANT TO LODGE: '))
        print('*********************************************')
        print('---------------------------------------------')
        print()
        if cash_in%10 != 0:
            print('----------------------------------------------------')
            print('****************************************************')
            print('AMOUNT YOU WANT TO LODGE MUST TO MATCH 10 RUPEES NOTES')
            print('****************************************************')
            print('----------------------------------------------------')
        else:
            amounts[n] = amounts[n] + cash_in
            print('----------------------------------------')
            print('****************************************')
            print('YOUR NEW BALANCE IS: ', amounts[n], 'RUPEES')
            print('****************************************')
            print('----------------------------------------')
    elif response == 'p':
        print('-----------------------------')
        print('*****************************')
        new_pin = str(input('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(input('CONFIRM NEW PIN: '))
            print('*******************')
            print('-------------------')
            if new_ppin != new_pin:
                print('------------')
                print('************')
                print('PIN MISMATCH')
                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('*************************************')
            print('-------------------------------------')
    elif response == 'q':
        exit()
    else:
        print('------------------')
        print('******************')
        print('RESPONSE NOT VALID')
        print('******************')
        print('------------------')

 

 

Output:

ENTER USER NAME: "jitendra"
jitendra
------------------
******************
PLEASE ENTER PIN: 1111
******************
------------------
-------------------------
*************************
LOGIN SUCCESFUL, CONTINUE
*************************
-------------------------
()
--------------------------
**************************
('Jitendra', 'welcome to ATM')
**************************
----------ATM SYSTEM-----------
-------------------------------
*******************************
SELECT FROM FOLLOWING OPTIONS: 
Statement__(S) 
Withdraw___(W) 
Lodgement__(L) 
Change PIN_(P) 
Quit_______(Q) 
:

 

: "S"
*******************************
-------------------------------
---------------------------------------------
*********************************************
('Jitendra', 'YOU HAVE ', 1000, 'RUPEES ON YOUR ACCOUNT.')
*********************************************
---------------------------------------------
-------------------------------
*******************************
SELECT FROM FOLLOWING OPTIONS: 
Statement__(S) 
Withdraw___(W) 
Lodgement__(L) 
Change PIN_(P) 
Quit_______(Q) 
:

 

: "W"
*******************************
-------------------------------
---------------------------------------------
*********************************************
ENTER AMOUNT YOU WOULD LIKE TO WITHDRAW: 400
*********************************************
---------------------------------------------
-----------------------------------
***********************************
('YOUR NEW BALANCE IS: ', 600, 'RUPEES')
***********************************
-----------------------------------
-------------------------------
*******************************
SELECT FROM FOLLOWING OPTIONS: 
Statement__(S) 
Withdraw___(W) 
Lodgement__(L) 
Change PIN_(P) 
Quit_______(Q) 
: 

 

: "L"
*******************************
-------------------------------
()
---------------------------------------------
*********************************************
ENTER AMOUNT YOU WANT TO LODGE: 150
*********************************************
---------------------------------------------
()
----------------------------------------
****************************************
('YOUR NEW BALANCE IS: ', 750, 'RUPEES')
****************************************
----------------------------------------
-------------------------------
*******************************
SELECT FROM FOLLOWING OPTIONS: 
Statement__(S) 
Withdraw___(W) 
Lodgement__(L) 
Change PIN_(P) 
Quit_______(Q) 
: 

 

: "P"
*******************************
-------------------------------
-----------------------------
*****************************
ENTER A NEW PIN: 1234
*****************************
-----------------------------
------------------
******************
CONFIRM NEW PIN: 1234
*******************
-------------------
NEW PIN SAVED
-------------------------------
*******************************
SELECT FROM FOLLOWING OPTIONS: 
Statement__(S) 
Withdraw___(W) 
Lodgement__(L) 
Change PIN_(P) 
Quit_______(Q) 
: 

 

Explanation:

This is a Python script that simulates an ATM machine, allowing users to check their account balance, withdraw money, lodge money, change their PIN, and quit the system.

The script begins by defining three lists: users, pins, and amounts, which hold the names of account holders, their corresponding PINs, and the amount of money they have in their accounts.

The script prompts the user to enter their username, which is then converted to lowercase for consistency. The script then checks whether the entered username exists in the users list, and assigns the corresponding index value to n.

If the username is found, the script then prompts the user to enter their PIN. If the entered PIN is correct, the script will proceed to the main menu, which offers the user a choice of actions to perform. If the user enters the wrong PIN more than three times, the script will exit.

In the main menu, the user can select from the following options:

  • S (Statement): display the user’s account balance
  • W (Withdraw): allow the user to withdraw money from their account
  • L (Lodgement): allow the user to lodge money to their account
  • P (Change PIN): allow the user to change their PIN
  • Q (Quit): exit the system

If the user chooses to withdraw or lodge money, the script will prompt the user to enter an amount. If the amount is not a multiple of 10, the script will prompt the user to enter a different amount. If the amount is valid, the script will update the user’s account balance and display the new balance.

If the user chooses to change their PIN, the script will prompt the user to enter a new PIN. If the new PIN is not exactly four digits long, the script will prompt the user to enter a different PIN.

If the user chooses to quit the system, the script will exit.

Copywrite © 2020-2024, CBSE Python,
All Rights Reserved