Python Python Basics Functions and Looping Create a Function

Christopher Hill
Christopher Hill
1,030 Points

How do I call my new function and call past in the argument 3?

squaring.py
def square(number):
    return number * number
    result = number * number * 3

2 Answers

Ave Nurme
Ave Nurme
15,612 Points

Hi Christopher

I believe you are stuck on Challenge Task 2 of 2. Let's walk you through this step by step.

Here's the text from the challenge:

Great now that you have created your new square method, let's put it to use. Under the function definition, call your new function and pass it the argument 3. Since your square function returns a value, create a new variable named result to store the value from the function call.

So, you created your new square method, great!:

def square(number):
    return number * number

For step no 2 we have to call our new function, here's how to do it in general:

square()

So, calling a function means you just add a set of parens after the name of your function. Next, we have to pass the function the argument 3, here's how to do it:

square(3)

And finally, we have to create a new variable called result and store the value from the function call:

result = square(3)

Here, we assign the value square(3) to a variable called result.

So if we put the pieces together, here's the final code which should pass the challenge:

def square(number):
    return number * number

result = square(3)

So, the number 3 actually goes instead of number in

def square(number):

and

return number * number

returns 3 * 3.

I hope this makes sense!

Christopher Hill
Christopher Hill
1,030 Points

This helps a ton, thank you so much!!

Ave Nurme
Ave Nurme
15,612 Points

Great to hear that, Christopher! Happy to help! :-)