Call and Response


Hi, I do not know why besides my square function returns the variable squared, in the result windows I get None

I think it should return the value of the variable

def square(n):
    """Returns the square of a number."""
    squared = n**2
    print "%d squared is %d." % (n, squared)
    return squared
# Call the square function on line 9! Make sure to
# include the number 10 between the parentheses.



it does, but then you need to store the response in a variable:

x = square(10)
print x

or call print directly on the function to print what the function returned:

print square(10)


Ok I get it! However I just want to mention that in my Windows shell for example I did get the output 100 instead of None again ...And the same in Jupyter

Does it have to deal with the version of Python? In my Windows Shell I have Canopy and in Jupyter Anaconda 3


yea, the python IDLE is so friendly to output what the function returns

if you where to make a script (lets say and run this in CMD using the python interpreter:


what the function returns is not printed.

I have no idea about Jupyter


Yes! you are right! I just did what you say and Indeed I have to print the result in order to see it



yep, in codecademy you write script (just like your, you don't work in the python IDLE, as you can see, there is the difference between script and IDLE


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