Python 3: (Functions) Practice Module Exam Question

I came across a quiz question in the Python 3: (Functions) practice module exam.

The question is: Write a function called adding_squares that takes two inputs, x and y and returns the sum of the squares of each of those numbers. For example, if adding_squares(2, 3) is called, it should return the sum of 4 and 9 , which is 13 .

My code produces the results (I believe ) the question is calling for:

def adding_squares(x, y):
   x = (x**2)
   y = (y**2)
  print(f"{x} + {y} = {x + y}")

adding_squares(2, 3)

However, when I submit to Check Answer I get this response:
Expected adding_squares(0,0) to equal 0 , but instead got None

I then changed the arguments to (0,0), and got the same response. Can you let me know what I’m doing wrong? Thanks!

The link to the section is:

However, I do not think it will take you to the exact question I’m referencing.


Welcome to the Codecademy forums! Next time, please format your code. (You can do that by wrapping it in triple backticks or by clicking on the code symbol in the editor.)

The question says to return the sum of the squares. Your function doesn’t do that.

1 Like

Hey byteblitz - Thanks for the reply! I see what I did wrong!
It should be: x = (x**2) and y = (y**2) ? :slight_smile:

I’m not sure what you meant by the code symbol in the editor. I see the icons at the top of the editor but I don’t see one for code.

Thanks again for your reply.

When I submitted my response to you I noticed it didn’t save the double asterisk (exponent) in my equation…

Hello, @method6058286472.

I edited your posts to preserve your code formatting. @byteblitz is talking about the
</> icon. If you click it first, you can paste your code in the space indicated. See How do I format code in my posts?

The instructions ask you to return the result not print() something that contains the result. Many new learners seem to confuse the two. Just because print() shows something on the screen doesn’t make it analogous to return.

1 Like

Hey Midlinder - Got it! Thank you so much for you help,and reformatting my code, I really appreciate it! :+1: