# 19/19 Function Works But Still Get EOF Error At The Very End

#1

I'm at Review - Built-In Functions

My code works well because I reinterpreted the instructions. I used either int OR float but did not use both in an 'OR' statement. If you think about it, there is only int or float. There is no third type that will work.

Now, that having been said, I am STILL getting an error message once the function has done its thing. The error message reads: unexpected EOF while parsing (, line 0)

What I expect to happen is for the function to end normally just like it does in Python 2.7 when I use the exact same code!

``````def distance_from_zero(num):
num = input("Type in a number: ")

if type(num) == float: # or type(num) == float:
print abs(num) # type(num)

else:
print "Nope"

return

distance_from_zero(0)``````

#2

@jrebollo,
You are over-writing the num parameter !!!

### the FUNCTION talk

``````def myFunc( param1, param2):
# Begin of =myFunc= FUNCTION-BODY
# this =myFunc= function- has 2 PARAMETERS param1 and param2
# param1 and param2 PARAMETERS are used
# as -local- VARIABLES throughout the =myFunc= FUNCTION-BODY
print( param1 + " and " + param2 )
#End of =myFunc= FUNCTION-BODY``````

If you want to call/execute the myFunc function
you will have to add a pair of parentheses to myFunc
like
myFunc()
As the myFunc function was defined
as having 2 parameters
you have to provide 2 arguments
in our case 2 string VALUES "Alena" and "Lauren"
like
myFunc("Alena","Lauren")

some quotes from the outer-world:

**argument is the value/variable/reference being passed in,
parameter is the receiving variable used within the function/block**

OR

**"parameters" are called "formal parameters",
while "arguments" are called "actual parameters".**

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++ function with 1 parameter using return-statement

``````def myFunction( param1 ):
# //Begin of =myFunction= FUNCTION-BODY
# //=myFunction= function has 1 PARAMETER param1
# //this param1 PARAMETER is used as a -local- VARIABLE
# //throughout the =myFunction= FUNCTION-BODY
return param1;
# //End of FUNCTION-BODY``````

You have defined a myFunction function
which takes 1 parameter param1
this param1 parameter is used
as a variable throughout the =myFunction= FUNCTION-BODY.

If you want to call/execute this myFunction function
and this myFunction function was defined
as having 1 parameter param1
you will have to provide 1 argument
in our case a "number VALUE" 4
myFunction( 4 )

some quotes from the outer-world:

**argument is the value/variable/reference being passed in,
parameter is the receiving variable used within the function/block**

OR

**"parameters" are called "formal parameters",
while "arguments" are called "actual parameters".**

#### ============================================

As you are using the return-statement in your myFunction function
you will only get a return-value no-display.
You can however capture this return-value in a variable
and then use the print-method to do a display.

``````theResult = myFunction( 4 )
print theResult``````

OR directly

``print myFunction( 4 )``

#3

Thanks for the help.
Please explain what you mean by saying that I'm over-writing my num parameter?
I put in the print statement at the end and it worked - sort of. Now I get an infinite loop that I can get out of only by hitting return. When I do however, I get the same error message. I'm looking to get past this current module and I'm getting closer, one little baby step at a time! Any firther input would be appreciated. Thanks.

#4

``````def distance_from_zero(num):
#num = input("Type in a number: ")

if type(num) == float: # or type(num) == float:
print abs(num) # type(num)

else:
print "Nope"

return

distance_from_zero(-11)``````