+ 1

def apply_twice(func, arg): return func(func(arg)) def add_five(x): return x + 5 print(apply_twice(add_five, 10))

Explain me the working of this program.

22nd Jul 2018, 3:14 PM
ADITYA SINHA
ADITYA SINHA - avatar
6 Respuestas
+ 14
apply_twice(func, arg) returns func(func(arg)), and add_five(x) returns x+5. So apply_twice(add_five, 10) =add_five(add_five(10)) =add_five(10+5) =add_five(15) =15+5 =20, which will be printed. Does that make sense?
22nd Jul 2018, 4:02 PM
Kishalaya Saha
Kishalaya Saha - avatar
+ 2
thanks bro @Kishalaya Saha
14th Oct 2022, 3:43 AM
Siddardha Reddy
+ 1
thank you @Kishalaya Saha
4th Apr 2020, 3:07 PM
Sergey Martynov
Sergey Martynov - avatar
0
Thanx
22nd Jul 2018, 4:44 PM
ADITYA SINHA
ADITYA SINHA - avatar
0
You're welcome, ADITYA! :)
22nd Jul 2018, 8:02 PM
Kishalaya Saha
Kishalaya Saha - avatar
- 1
No
30th Sep 2019, 4:32 PM
Sk Samim
Sk Samim - avatar