Call and Response


#1


https://www.codecademy.com/en/courses/python-beginner-c7VZg/1/2?curriculum_id=4f89dab3d788890003000096#

The code provided is:

def square():
    """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.

This should have allowed me to input:
square(10)
on line 9 and provide me with the answer. Instead, I received an error stating that:
"""Traceback (most recent call last):
File "python", line 9, in
TypeError: square() takes no arguments (1 given)""" emphasis added

To fix this, I added an """n"""" to the parenthesis. My final working code looked like this:


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.
square(10)


#2

I have since realized I somehow altered the code myself, and the original code was already
def square(n)

I also don't know how to delete posts XD

Sorry about this extra clutter


#3

can you show me the whole console? cause I can't make the code run anyway. It makes me define the 10 number and I don't know how.


#4

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