Python Python Basics Functions and Looping Create a Function

figuring out how to start this...

Hi, in Python Basics, the problem "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." I'm having trouble understanding where to begin. I've gone back through the previous video, 'Returning Values', and still seem lost.

What I tried to do was use... "def square(number) : return math.ceil(..."

... and then I completely lose where to go from there. Any help would be appreciated. Thanks!

squaring.py
def square("number")

1 Answer

Ruben Ponce
Ruben Ponce
Full Stack JavaScript Techdegree Student 12,035 Points

It seems that you tried to make your parameter a string by using quotations around number. What they wanted were an actual number. So a parameter is kind of like a variable that your function will use somewhere inside it to return a value. For example to square the number 5, you would take your function def square(5) : square = 5*5 return square. by the same logic, your parameter will be a variable. so ```def square(number): square = number*number

return square```.

Joshua Wilson
Joshua Wilson
1,005 Points

thanks a lot that worked perfect. sometimes its so simple I get stuck