0
needing help with a test (python)
Fill in the blanks to pass the function "square" as an argument to the function "test": square(x): return x * x def test(func, x) print(func(x)) test( , 42)
4 Antworten
+ 5
You have lots of blank spaces in your question ;)
You can pass the name of the function plainly just as any parameter.
test(square, 42)
+ 4
def square(x):
return x * x
def test(func, x):
print(func(x))
test(square, 42)
+ 1
def
:
square
+ 1
def
:
square