0
Help!!! :(
3 Respostas
+ 3
I believe the comma in line 2 is a typo. But ignoring that:
test(func, 2) # test takes two arguments, a function and an argument for the function.
# in it's body it calls the function with the argument and the result of the call is passed as argument to the function again
# in this case the function passed to test is mult and the argument to mult is 2
# calling mult(2) returns 2*2 = 4. So now 4 is passed to mult again by test
# mult(4) returns 4*4 = 16. So 16 is the value returned from test and what is printed to the screen.
0
It says what is the output of this code?:
0
def test(func , arg):
return func(func, (arg))
def mult(x):
return x*x
print(test(mult,2))