Welcome to the Treehouse Community
Looking to learn something new?
TASK 1:2 AFTER CHECK_PLEASE.PY
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
Eric M11,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.
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
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
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