0

I understand the code

def test(func, arg): return func(func(arg)) def mult(x): return x * x print(test(mult, 2)) I don't understand the code and how in the world it gives 16. I don't understand.

21st Aug 2022, 2:30 AM
Alvin Phyo Htet
Alvin Phyo Htet - avatar
1 Odpowiedź
+ 6
Alvin Phyo Htet test(mult, 2) = mult(mult(2)) = mult(2 * 2) = mult(4) = 4 * 4 = 16 Here func is known as mult because you have passed function 'mult' as an argument. https://code.sololearn.com/cgfonDJu8pH0/?ref=app
21st Aug 2022, 2:33 AM
A͢J
A͢J - avatar