+ 2
def square (x): return x*x def test(func,x): print(func(x)) test (square,42)
if i want output so what it will be for test
3 Answers
+ 24
You can use the code playground to test outputs...
test(square, 42) will send a function (square) and x (42) to test function
test function prints the value returned from square i.e passes 42 to square function which will be multiplied later
square returns multiplication of the two i.e 42*42 = 1764 which is printed
+ 2
def
square(x):
return x * x
def test(func, x):
print(func(x))
test(square, 42)
0
wtf