Python Python Basics Functions and Looping Create a Function

How do I call my call my function
def square(number):
    return number * number

result = square("number")


2 Answers

Jonathan Grieve
Jonathan Grieve
Treehouse Moderator 85,481 Points

Instead of the print() method you just need to call the function by specifying its name, followed by curly braces. Then you pass in the value that the function is expecting.

Remember when you declared the function like this def square(number): You passed in a variable which you used an argument for the function. number.

As you see the function returns the result of a calculation. All you have to do is provide the number and that is what happens in a function call.


Perfect. You're awesome Jonathan