+ 2

python

What is the output of this code? def test(func, arg): return func(func(arg)) def mult(x): return x * x print(test(mult, 2))

26th Sep 2017, 12:34 AM
Nikhilesh Boppana
Nikhilesh Boppana - avatar
3 Réponses
+ 3
It's a composition of functions. The value 2 is being sent through the func, mult, and the output (4 in this case) is sent into the func, mult. This output, 16, is the value returned to the print function.
26th Sep 2017, 2:03 AM
Mark McGhee
Mark McGhee - avatar
+ 2
16
26th Sep 2017, 12:37 AM
LordHill
LordHill - avatar
0
It's a quiz question I am sure. You can check correct answers. Just scroll a bit to see "View Correct Answers"
26th Sep 2017, 1:13 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar