December 2nd, 2004, 01:28 PM
I have many scripts that I want to convert to exes but it just does not work because it always says that a EOF Error has come in this script:
print "calc for a calculator"
print "fib for the Fibonacci Sequnence"
a= raw_input("Which option would you like to choose?")
if a== "calc":
elif a== "fib":
in the fifth line by the raw_input("Which option would you like to choose")
And an other question how do u exit a module but then u can go into it again is it with "reload" but i dont understand.
please help me
December 2nd, 2004, 08:35 PM
Hmm, I would like to help you with your raw_input problem only your question doesn't seem to make much sense. Also the line, "in the fifth line by the line "raw_input("Which option would you like to choose")" seems to be randomly placed. Because of this I have no clue what exactly you need help with.
December 3rd, 2004, 05:06 AM
You are using the import command to run code in your modules. This is the problem.
You are right; the only way to re-execute the module would be to use the reload command. But this is not necessary. Normally, code run at import time is only used to configure the module or prepare things for later execution. Your modules need some functions that you can call after the module is imported...
I suggest you investigate writing functions, you can then do things like:
In your calc module you could have a function like this:
a = raw_input("Type 'calc'' or 'fib' or 'quit'")
if a not in ['calc','fib','quit']:
if a == 'quit':
if a == 'fib':
fibonacci.do_fibonacci() # do_fibonacci is a function you write in the fibonacci module.
elif a =='calc':
calc.do_calc() #do_calc is a function in the calc module
I hope this helps
#the code to do calculations
p.s. use code tags!
December 3rd, 2004, 02:35 PM
ya but could you please explian the "def" thingy because i dont understand it
and please some examples
December 3rd, 2004, 06:35 PM
Originally Posted by monkeyman23555
You gotta have parentheses after the function name, even if there are no parameters to the function, gotta have a colon after parentheses, and the body of the function has to be consistently indented.
list = [1, 2, 3]
[1, 2, 3]
def multiply(a, b):
December 4th, 2004, 05:31 AM
hm i get it a bit but wait
is it just like a thing name and then it just if u type that it asks u for the (a, b)and then it multiplys them like that oh ok thats good i am going to try something and then put the script put here
December 4th, 2004, 01:19 PM
No, this does not ask the user for a, b, but you could make it so
And then you can call the multiply(a, b) function like this:
x = input("Please enter the first number: ")
y = input("Please enter the second number: ")
Am I supposed to sign here?