+ 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.
6 ответов
+ 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?
+ 2
thanks bro @Kishalaya Saha
+ 1
thank you @Kishalaya Saha
0
Thanx
0
You're welcome, ADITYA! :)
- 1
No