Is passing a number in the same as using that number as the argument?

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.

Thanks!

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
'*************************'
>>> 
2 Likes

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)
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)
42
>>> foo(0)
>>>

which can be boiled down to ,

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

>>> foo(42)
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.

4 Likes