Python Python Basics Functions and Looping Create a Function

Khan Family
Khan Family
377 Points

Challenge Task 2

What am I doing wrong and can you please explain?

squaring.py
def square(number):
    return number * number
result = square(5)
print(result)

4 Answers

KRIS NIKOLAISEN
PRO
KRIS NIKOLAISEN
Pro Student 49,714 Points

You receive error: AssertionError: 25 != 9 : Make sure you store the return value from the function in a variable named result.

The argument passed in should be 3 not 5. From the instructions:

call your new function and pass it the argument 3

Paul Nay
Paul Nay
566 Points

Hello I am wondering why I am getting the incorrect answer. I've tested my code on the workspace to ensure it works.

def square(number): return number ** 2

num_chosen = int(input("Please enter a number to square\n")) result = square(num_chosen)

print("The square of {} is {}".format(num_chosen,result))

KRIS NIKOLAISEN
PRO
KRIS NIKOLAISEN
Pro Student 49,714 Points

Paul, the checker doesn't respond to the input function. For task 1 you just need the function which you have.

def square(number):
    return number ** 2
Paul Nay
Paul Nay
566 Points

Ah thanks for pointing that out. Appreciate the help.