"Review: Built-In Functions"



def distance_from_zero(num):
if distance_from_zero(num):
   return abs
   return "Nope"


I think in this condition you have to verify if the numebr ( num ) is float or integer ! Yes ?

 I think that you are correct, sir.  I am still trying to figure out this module myself.  Here is my code:

def distance_from_zero(num)int:
if distance_from_zero (num)int:
return "Nope
return abs


Ian Michael Jones


Maybe you should verify the number then?

Running the same function inside itself with the same argument won't work too well.


this is the completed code:

def distance_from_zero(n):
if type(n) == int or type(n) == float:
return abs(n)
return "Nope"

 Ms. Pezzotta, I ran the code that you posted and I received this error.  "Oops, try again. It looks like you have a NameError. Maybe you forgot to create a function called distance_from_zero? Check the error message for more info! - global name 'distance_from_zero' is not defined."


Ian Michael Jones


please help i really dont know what happened. any ideas?

def distance_from_zero(y):
if type(distance_from_zero) == int or float:
return abs(distance_from_zero)
return "Nope"


ok never mind i know what i did now.


get in two ways


def distance_from_zero (ps):
if type (ps) == int or type (ps) == float:
return abs (ps)
return "No"

and that

def distance_from_zero (s):
if type (s) == int:
return abs (s)
elif type (s) == float:
return abs (s)
return "No"


that code is completely correct just check your spell or common mistaks and make sure if and else both have the returns....


I tried and it didn't work at all