Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.



Challenge Task 1 of 2 Create a function named square. It should define a single parameter named number.

In the body of the function return the square of the value passed in.

im so lost :( im not asking for answers, but do you guys think you can help me find the topic in which this was discussed at least? or some sort of quick tutoring..

so far I want to

def function_name (square) ????? but I keep getting an F on that so OBVIOULSY NOT THAT

1 Answer

Eric M
Eric M
11,515 Points

Hi Jazmin, Let's take a look at each component of this task. Create a function named square. It should define a single parameter named number.

Create a function named square. Functions are created (or defined) with the keyword def and a function name is its identified that follows the def keyword, doesn't have spaces, and ends in parentheses.

def square():

It should define a single parameter named number Parameters (which are sometimes referred to as arguments) are the variables that go inside the parentheses, and they can be used by the function based on their name. So if I had a function that looked like:

def draw_circle(radius_in_pixels, color):

The function name is make_paper, it has one two parameters the first is named radius_in_pixels and the second is named color

If I call the function somewhere else in my program I would do it as below. When we call the function we include arguments in the function call, the values of our arguments become the values of the parameters within the function

draw_circle(5, "green")

So within our function:

def draw_circle(radius_in_pixels, color):
        # radius_in_pixels would be equal to an integer of value 5, if called as above
        # color is a string containing "green", if called as above
        # for instance, we might write:
        diameter_in_pixels = radius_in_pixels * 2