Review: Built-In Functions | Help plz!


#1


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

def distance_from_zero(-6):
if type(-6) == int or type(-6) == float:
return abs(-6)
File "python", line 1
def distance_from_zero(-6)
^
SyntaxError: invalid syntax


 def distance_from_zero(-6):
    if type(-6) == int or type(-6) == float:
        return abs(-6)


#2

If you consider that your function should work for any number as input, you may realise that -6 is not of special interest and therefore shouldn't be mentioned in your code at all. (why would that particular number be mentioned? why not 7? why not 8? 100? All of them?)


#3

I need help on what a special character would be


#4

I do not know what it is you are asking, however I do suggest reviewing whichever lesson(s) talked about function parameters.

For example, in this function:
f(x) = x + 1

x is a parameter. It doesn't say 100 or -6 or 37, it's instead a name that refers to whatever the argument to the function is


#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.