Show me the way (19. Review: Built-In Functions)


#1



It's not necessary for the lesson but can someone show me how you would modify this code so that it takes user input and puts that in for 'a'. Like so instead of typing in 'distance_from_zero(whatever number)', the program would just ask you for a number and put that in the parameters. Thank you in advance


def distance_from_zero(a):
    if type(a) == float or type(a) == int:
        return abs(a)
    else:
        return "Nope"
Replace this line with your code.


#2

So the program asks you the number, right? Then my code would probably be

x = raw_input ("Insert your preferred number here: ")

distance_from_zero (x)

#3

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