Python Python Basics Functions and Looping Create a Function

this return task question is too vague.

This return task question is too vague im not sure what it asking. it says square but is not defined but is printed.......
def square(number):
    return square(number**)

1 Answer

Alex Koumparos
Alex Koumparos
Python Web Development Techdegree Student 33,847 Points

Hi Carlos,

The question wants you to write a function called square that takes a number (number) and then returns a value that is the square of that number (i.e., that number multiplied by itself).

There are a couple of ways you can compute the square, for example you could use the multiplication operator (*) to multiply number by number. Or, you could use the the exponentiation operator (**) to raise number to the power 2. When using either of these operators they take the form a <operator> b, so, for example, multiplying 3 and 4 would be 3 * 4 or raising 6 to the power 3 would be 6 ** 3.

Once you have calculated the value, you just return it. In your current code you have created an infinitely recursive function (calling square inside square) that never actually returns a value it just keeps calling itself until the recursion depth limit is reached, at which point the application will crash.

Hope that clears everything up.