I am running Python (IDLE) 2.5.4
Here are my examples...
Simple Banking Program In Python [CODEBOX #1]
def main(): print "############################ Python Internation Bank #########################" print " [A] Open An Account" print " [B] Access Account" print "##############################################################################" def userInput(): getinput = raw_input("Test >>> ") if getinput == 0: ### Open Account Script ### print "Open Account" if getinput == 1: ### Access Account ### print "Access Account" else: main() return main()
Simple Guest Book In Python [CODEBOX #2]
## Declaring strings as raw_input to get information from the user. ## ## Guest Book 1.0 ## 0 = "y", "Y" 1 = "n", "N" def valfunc(): ## Validation using text_strings as user input?? Needs Work ## ## String Error: Syntax ## validation = raw_input('Is this correct? <Y/N>: ') if validation == 0 print "CORRECT NAME" if validation == 1 print "INCORRECT NAME" main() if validation != 0, 1; print "Else Statement: Incorrect Syntax Error" valfunc() return def mainfunc(): print "Guest Book Check-in\n"; LastN = raw_input('What is your last name?: ') FirstN = raw_input('Thank you, now please type your first name?: ') print "Thank you for signing into the guest book. Your name is " + LastN + ", " + FirstN valfunc() return mainfunc()
Now, I see that this code is unfinished, but due to the fact that I am not just trying to refresh myself in programming. I have been programming on and off for a few years now. I am studying Computer Science and teaching myself "efficiency" in programming. So, I have an outline done and a flow chart that I am using to outline each one of my programs.
1. ) I need to know an efficient way to assign these variables to the integers. [A, a] = 1 [B, b] = 0 [N, n] = 1 [Y,y] = 0
Now I was certain I was past variables, strings, and integers.. But, it seems I am missing something in syntax with python that I am not doing right.
2. ) I am using these variables as a method to have Options in a text menu, as well as to get data, assign it, and check it.
Is there a more efficient way to do this process? Any pointers are appreciated.
Update: I have tried declaring them as global variables outside of my functions. One problem I am facing is that I am getting stuck in an infinite loop with [CODEBOX #2] on line
Line 14;
print "Else Statement: Incorrect Syntax Error"
I have tried various other structures for my variables. But, Python doesn't support case or classes so I have to use if statements. My code might be a little rough to follow due to the fact I was deconstructing and constructing it a few times over, but I think I kept it pretty cleaned up from all the changing and rearranging I did. I hope you all follow what I am saying and what I am focussing on accomplishing with this task. Thanks again for reading guys!
Thanks guys! Glad to be back,
Donovan