Functions: Call and Response 3/19


#1

On 3/19 I am tasked with defining the function square:

def square(n):
“”“Returns the square of a number.”""
squared = n ** 2
print “%d squared is %d.” % (n, squared)
return squared

Can someone explain to me why I have defined it as ‘square’ yet all the function within say ‘squared?’

At the end I have to call the square function: square(10) and it gives me the correct answer despite being mixed between square and squared


#2

square is the function, squared is a variable within the function, which you define here:

squared = n ** 2

#3

Thanks for the help!


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.