Python Python Basics Functions and Looping Create a Function

Create a function named square. It should define a single parameter named number. In the body of the function, return

squaring.py
def square(number): 
   return (5*5)

3 Answers

Steven Parker
Steven Parker
203,727 Points

This code always returns 25 (5*5), but it should return the square of the "number" passed as an argument instead.

Sean Layton
Sean Layton
1,645 Points
def square(number): 
   return (number*number)
Filip Grąz
Filip Grąz
282 Points

Hi

I have problem with second task, please tell me what is wrong with my code?

def square(number): value = (number * number) return(value)

result = square(3) 
print(result)
Steven Parker
Steven Parker
203,727 Points

It's impossible to be sure with unformatted code, but I'd guess you have an indentation issue.

Also, never post a question as an "answer" to another one — always start a new, fresh question.

And when posting code, be sure to format it using the instructions from the Markdown Cheatsheet found below the "Add an Answer" area :arrow_heading_down:   Or watch this video.