FAQ: Learn Python: Functions - Review: Built-In Functions

This community-built FAQ covers the “Review: Built-In Functions” exercise in Codecademy’s lessons on Python.

FAQs for the Codecademy Python exercise Review: Built-In Functions:

Join the Discussion. We Want to Hear From You!

Have a new question or can answer someone else’s? Reply (reply) to an existing thread!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources about Python in general? Go here!

Want to take the conversation in a totally different direction? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account, billing, Pro, or Pro Intensive? Reach out to our support team!

None of the above? Find out where to ask other questions here!

1 Like

Other FAQs

The following are links to additional questions that our community has asked about this exercise:

  • This list will contain other frequently asked questions that aren’t quite as popular as the ones above.
  • Currently there have not been enough questions asked and answered about this exercise to populate this FAQ section.
  • This FAQ is built and maintained by you, the Codecademy community – help yourself and other learners like you by contributing!

Not seeing your question? It may still have been asked before – try (search) in the top-right of this page. Still can’t find it? Ask it below by hitting the reply button below this post (reply).

2 posts were split to a new topic: Why Does This Print Statement Not Execute?

6 posts were split to a new topic: How to Print the Output of a Function?

3 posts were split to a new topic: Why Does This Work With Numbers, But Not Strings?

Hi! I’m on Python (something pretty new for me).

On functions, I’m trying to figure out what “return” does. For example

def biggest_number(*args):
print max(args)
return max(args) -----------> here

What does it do?


have you checked with FAQ:

What does return do?

hi! I’m not sure why this doesn’t work, can anyone tell me?


1 Like


With the code in this exercise, I tried to make the script receive input from the console, but it returns ‘Unicode’ as the type. The function works fine if you pass the argument from code, but do I need to define/transform the raw_input to make it work?

Here is my code:

x = raw_input("Enter a number: ")

print type(1)
print type(1.0)
print type(x)

print distance_from_zero(x)

def distance_from_zero(x):
if type(x) == type(1) or type(x) == type(1.0):
return abs(x)
return “Nope”

print distance_from_zero(-6)
print distance_from_zero(-56.983)
print distance_from_zero(“Abc”)

1 Like

same problem :confused:

please see this topic:

How to ask good questions (and get good answers)

Asking better questions will get better response.

I guess it was fixed, because it now works two years later.

I’m trying to do something similar, and I think the problem is that raw_input() always outputs a string.
I tried using x = int(rawinput("Enter a number: ") to transform the input to an integer, which works if the user types an integer, but fails if they type a float or a string.

Do you still have a question, or?

Not really, just adding information to @stephenmak5974281141 question.
I assume that if you want to use raw_input() for this exercise, you need to check the input somehow before accepting it to the function?

or you could write a separate function which validates the input.

Still happening. What’s the fix?

The instructions: " First, def a function called distance_from_zero , with one argument (choose any argument name you like)."

So I “choose any argument name [I] like”: “distance_from_zero(5)” and get the error. I look at the solution and it says “distance_from_zero(num)” and wont let me do anything but that: “num”

Change the instructions so that the answer is accepted, please. Spending time to get it right when it’s already correct is so exhausting as this is a constant problem throughout all these exercises. I always want to figure out my mistake first just to see there isn’t one. There’s just a specific way you want the answer yet didn’t say that or it’s just not reading it properly. I can’t take pics but I’ve had the exact answer as the Solution but it kept not being accepted.

You got an error because you cannot assign an integer as a parameter in
the function.

In python, a paramater is variable, and should follow the rules for a valid variable name.

Rules for Python variables:

  • A variable name must start with a letter or the underscore character.
  • A variable name
  • A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )
  • Variable names are case-sensitive (age, Age and AGE are three different variables)

You cannot assign the integer 5 as a parameter because a variable name can’t begin with a digit.
So, try naming the parameter to ‘anything argument name you like’ EXCEPT integers and keywords.

Hello. The answer to this question might be quite technical, but I’m still curious. I hope someone can give me an answer.

In the course of debugging my code, I had written print(type(dis)) at the beginning of my function, like so:

def distance_from_zero(dis): print(type(dis)) if type(dis) == int or type(dis) == float: return abs(dis) else: return "Nope"

The output to the console was a long list of varying types, including some things we haven’t learned at this point, such at “dict” and “tuple”. What’s up with that? What’s going on with the dis variable in the course of this program?

Thanks for any insight.