19: reviewing built in functions


#1

I am not sure what is wrong but the error is :
File “python”, line 1
def distance_from_zero(20):
^
SyntaxError: invalid syntax

def distance_from_zero(20):
if type(20) == int or type(20) == float:
return abs(20)
else:
return “Nope”



Replace this line with your code. 



#2

line 1, a function parameter has to be a valid variable name, 20 is not a valid variable name


#3

I did this:
def distance_from_zero(num):
if type(num) == int or type(num) == float:
return abs(num)
else:
return "Nope"
print distance_from_zero(num)

but the error says:

Traceback (most recent call last):
File “python”, line 6, in
NameError: name ‘num’ is not defined


#4

Figured it out!
def distance_from_zero(num):
num == 3
if type(num) == int or type(num) == float:
return abs(num)
else:
return "Nope"
print distance_from_zero(3)
THANKS


#5