ok you will probably be sick of my posts but i have tryed and got this far, i ripped the program to pieces and started again. basically its a atm program that i have to do for college. if anyone can see why its not workin properly it would be a great help.

import pickle
f= open ("pin.pck", "w")
pickle.dump(1234, f)
pickle.dump([1,2,3,4], f)
f.close()
#Pin Validation
def pin():
f=open("pin.pck", "r")
x=pickle.load(f)
print
print " ***Welcome to the bellco banking system***"
print "============================================="
print "Please insert your card"
print ""
print "Card Accepted"
print ""
pin = input ("Please insert your pin number to the keypad: ")
print "=============================================="

#Checks if pin is within range of 1000 to 9999
while True:
if pin>=1000
print "Pin accepted"
if pin =<9999:
print "Pin accepted"
print
if pin== x:
print "Valid Pin"
print
if pin != x:
print "Invalid Pin"
print
pin()
break
else:
print "Invalid Pin"
pin()
break

#Create Menu
def createmenu():
print " ***Welcome to Bank ATM*** "
print "=================================="
print " Please select one of the below "
print " 1 Withdrawal only"
print " 2 Withdrawal With Statement"
print " 3 Statement only"
print " 4 Quit"
print "=================================="

#Statement Procedure
def statement():
print "Your balance is $" #balance details
print
print "Thank you for using this Bank ATM"
print "=================================="

#Withdrawal Procedure
def withdrawal():
print "================================"
print " Please select one of the below "
print " 1 $50"
print " 2 $100"
print " 3 $150"
print " 4 $200"
print "================================="

amount= raw_input ("Please make your selection:")
print "===================================="
while True:
if amount == "1":
print "You have chosen to withdraw $50"
print
print "Please take your cash"
print "================================="
break
#Insert coding to remove cash from balance
elif amount == "2":
print "You have chosen to withdraw $100"
print
print "Please take your cash"
print "==================================="
break
#Insert coding to remove cash from balance
elif amount == "3":
print "You have chosen to withdraw $150"
print
print "Please take your cash"
print "================================="
break
#Insert coding to remove cash from balance
elif amount == "4":
print "You have chosen to withdraw $200"
print
print "Please take your cash"
print "================================="
break
else:
print "Invalid Selection - Re-enter"
withdrawal()
break
#Menu Options
def selectoption():
keypadinput = raw_input ("Enter your selection: ")
while True:
if keypadinput == "1":
print
print "You have chosen to make a withdrawal"
withdrawal()
break
elif keypadinput == "2":
print
print "You have chosen to make a withdrawal withdrawal with a statement"
withdrawal()
statement()
break
elif keypadinput == "3":
print
print "You have chosen to print a statement"
statement()
break
elif keypadinput == "4":
print
print "Thank you for using this Bank ATM"
break
else:
print "Invalid Selection"
selectoption()
break
#Initiate Program
pin()
createmenu()
selectoption()

Recommended Answers

All 6 Replies

Overall, this is a great improvement in organization!

Let's start by posting the code with the [ code= Python ] [/ code ] tags:

import pickle
f= open ("pin.pck", "w")
pickle.dump(1234, f)
pickle.dump([1,2,3,4], f)
f.close()
#Pin Validation
def pin():
    f=open("pin.pck", "r")
    x=pickle.load(f)
    print
    print " ***Welcome to the bellco banking system***"
    print "============================================="
    print "Please insert your card"
    print ""
    print "Card Accepted"
    print ""
    pin = input ("Please insert your pin number to the keypad: ")
    print "=============================================="

    #Checks if pin is within range of 1000 to 9999
    while True:
        if pin >= 1000:
            print "Pin accepted"
        if pin <= 9999:
            print "Pin accepted"
            print
        if pin == x:
            print "Valid Pin"
            print
        if pin != x:
            print "Invalid Pin"
            print
            pin()
            break
        else:
            print "Invalid Pin"
            pin()
            break

#Create Menu
def createmenu():
    print " ***Welcome to Bank ATM*** "
    print "=================================="
    print " Please select one of the below "
    print " 1 Withdrawal only"
    print " 2 Withdrawal With Statement"
    print " 3 Statement only"
    print " 4 Quit"
    print "=================================="

#Statement Procedure
def statement():
    print "Your balance is $" #balance details
    print
    print "Thank you for using this Bank ATM"
    print "=================================="

#Withdrawal Procedure
def withdrawal():
    print "================================"
    print " Please select one of the below "
    print " 1 $50"
    print " 2 $100"
    print " 3 $150"
    print " 4 $200"
    print "================================="

    amount= raw_input ("Please make your selection:")
    print "===================================="
    while True:
        if amount == "1":
            print "You have chosen to withdraw $50"
            print
            print "Please take your cash"
            print "================================="
            break
        #Insert coding to remove cash from balance
        elif amount == "2":
            print "You have chosen to withdraw $100"
            print
            print "Please take your cash"
            print "==================================="
            break
        #Insert coding to remove cash from balance
        elif amount == "3":
            print "You have chosen to withdraw $150"
            print
            print "Please take your cash"
            print "================================="
            break
        #Insert coding to remove cash from balance
        elif amount == "4":
            print "You have chosen to withdraw $200"
            print
            print "Please take your cash"
            print "================================="
            break
        else:
            print "Invalid Selection - Re-enter"
            withdrawal()
            break
#Menu Options
def selectoption():
    keypadinput = raw_input ("Enter your selection: ")
    while True:
        if keypadinput == "1":
            print
            print "You have chosen to make a withdrawal"
            withdrawal()
            break
        elif keypadinput == "2":
            print
            print "You have chosen to make a withdrawal withdrawal with a statement"
            withdrawal()
            statement()
            break
        elif keypadinput == "3":
            print
            print "You have chosen to print a statement"
            statement()
            break
        elif keypadinput == "4":
            print
            print "Thank you for using this Bank ATM"
            break
        else:
            print "Invalid Selection"
            selectoption()
            break
#Initiate Program
pin()
createmenu()
selectoption()

This code fixes a couple of syntax errors.

Anyways, when I run it I get this:

***Welcome to the bellco banking system***
=============================================
Please insert your card

Card Accepted

Please insert your pin number to the keypad: 5155
==============================================
Pin accepted
Pin accepted

Invalid Pin


Traceback (most recent call last):
  File "C:/Python24/atm1.py", line 131, in -toplevel-
    pin()
  File "C:/Python24/atm1.py", line 33, in pin
    pin()
TypeError: 'int' object is not callable

This error message indicates that the name 'pin' points to an integer. So a good place to start is to see if somewhere in the function that contains line 33, you assigned 'pin' to an integer.

Hope this gives you a start,
Jeff

cant figure out where to start!!
when i made pin = to something it was an input but i dnt know where to find it any wee hint woul dbe a help.

If I enter any pin number, the program will accept it because it is > 1000 or < 9999

#Checks if pin is within range of 1000 to 9999  
valid = 0
while not valid :
     if (pin > 999) and (pin < 10000) :
          print "Pin accepted"
          if pin== x:
               print "Valid Pin"
               valid = 1
          else :
               print "Invalid Pin"
               pin()
     else :
          print "pin must be between 1000 and 9999"
          pin()

There is a simplier way to do the cash withdrawal as well

def withdrawal():
     withdrawal_dic = {}
     withdrawal_dic[1] = 50           ## all of these could be done on one line
     withdrawal_dic[2] = 100         ## or with a for loop and +50 each time
     withdrawal_dic[3] = 150
     withdrawal_dic[4] = 200
     max = len(withdrawal_dic)     ## assumes all of the keys (numbers) are sequential
     max_p1 = max + 1
     # now if you want to add more amounts or change one,
     # you just alter the dictionary         
     valid = 0
     while not valid :
          print "================================"
          print " Please select one of the below "
          for key in range( 1, max_p1) :
               print " %d $%d" % (key, withdrawal_dic[key])
          print "================================="
 
          amount= raw_input ("Please make your selection:")
          print "===================================="
          if (amount > 0) and (amount <= max) :
               print "You have chosen to withdraw $%d" % (withdrawal_dic[amount])
               print "\nPlease take your cash"
               print "================================="
               ##-----  NOTE: the following line should come before the break
               #Insert coding to remove cash from balance
               valid = 1
          else:
               print "Invalid Selection - Re-enter\n\n"

I haven't tested this, but you can certainly find any typos, etc, so I'll be lazy and not test it myself.

Finally, you can also use a dictionary for the menu options = def selectoption(). The dictionary may be a dictionary of lists. The option number, 1,2,3,4, etc is the key. Each key has a list = [ "menu message", "you have chosen to message", function_to_execute ]. You can execute the function in dic_list[2] for this example, like the following simplified example. Again, as with the withdrawal amounts, you only have to change or add to the dictionary to edit the menu

##  define some simple function to execute
def funct():print 12345
#
## use exec to call the function
x = 'funct()'
exec(x)

thanks for that mate it really helped i have another question, well 2 questions the pin number enterd has to be assigned to a list of customer store in a pickle file, and there must be a pin number stored (1357) for administative purposes which allows for the customer details to be changed and new files added. can you give me a hand trying to implement this into my code. also i have to have a random message (you know like when you go to the atm and it says "keep your pin safe" or "look out for any suspicious devices" something like that and there has to be a count down to christmas counter thingy added in as well ive just been told these things and the coursework has to be handed in this week any help would be a great boost to the program and help me pass the class.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.