FAQ: Introduction to Functions - Parameters


This community-built FAQ covers the “Parameters” exercise from the lesson “Introduction to Functions”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Computer Science
Data Science

FAQs on the exercise Parameters

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

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

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

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

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

1 Like

I don’t get where to add the function. Everywhere i add it, after i remove the number value, I get a syntax error.

1 Like

Please point us to the exercise page by posting its URL, and include your code and the error message.



Where do I add function so I can delete number = 5?


Now, modify the function definition so that it has a parameter called number . Then delete the number = 5 assignment on the first line of the function.

Pass the number 1 into your function call.

We start out with,

def mult_two_add_three():
  number = 5

The parameter list is empty, and the variable is declared and defined directly in the function body.

We want to be able to supply the function with any value for number so define it in the parameter list, as the instruction suggests…

def mult_two_add_three(number):
  #number = 5

Comment out the declaration line and run the code with the arguments given in this and the next three steps.


Are these two statements equivalent?

“Pass the number 1 into your function call.” and

Call the function with the value 5 as the argument.

I ask because I do not know what the difference between these two statements is and also because, not having "passed the number ‘1’ " into my function call I’m still getting the green check mark when I run the code.



Yes, they are. What we pass in through the function call argument becomes the formal parameter of the function, and given a local name.

>>> def foo(number):     # formal parameter => number
    return ''.join(['*'] * number)

>>> foo(25)              # argument         => 25

so the way I understand it after reading this is when you call upon the function, after changing the formal parameter. you change the number at the end of the function when called upon. i.e.
mutl_two_add_three(1) or what ever variable you would like with in the ()?, I don’t understand why I was still getting an error


For your error, we will need to see your raw code. Please post it in a reply.

Think of a function as having one entrance and two exits. At the entrance they take the objects you enter with. There is some stuff done with the objects you brought in and the outcome is returned to you on your way out, else they (the objects) are discarded and you take the other exit.

>>> def foo(x):
        return x if x else None

>>> foo(42)
>>> foo(0)

Above we evaluated the truthiness of x, whereby the response was that value, or, None (what it would be if there was no return in the function).

x is the parameter, 0 and 42 are the arguments. Note that the function is only defined once. We can call it millions of times, if need be. In this case we called it twice. The value we place in the argument, i.e., within the parens, (), is the value that will be used by the function to carry out its operation. The name of the value as the function sees it is given in the definition line, def foo(x).

It’s okay if that caught you off guard. It should. Consider a simpler, more naive reckoning of the above…

>>> def bar(x):
        if x: return x 
        else: return None

>>> foo(42)
>>> foo(0)

which can be boiled down to ,

>>> def bar(x):
        if x: return x 

>>> foo(42)
>>> foo(0)

We came in with x and went out with x if it was truthy. Otherwise we took the other exit. Python returned None for us.