0
Functional Programming
def apply_twice(func, arg): return func(func(arg)) def add_five(x): return x + 6 print(apply_twice(add_five, 11)) Why output is 23? It should be 22.
5 Answers
+ 5
The control flow is something like this-
1. add_five receives 11 and add_five.
2. It has return statement with branched function call.
func(func(arg)) = func(17) (it adds 6 to 11)
func(17) = 23 (it adds 6 to 17)
+ 9
Why would you call a function that adds 6 "add_five"? Variable names should help the readers not confuse them đ
+ 6
David Ashton Ă la SL quiz. :>
+ 6
Hatsy Rei Hmm Jash's question is the same as https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/2459/ first lesson except there add_five() returns x + 5 and the argument is 10 not 11. I couldn't find the quiz (?)
+ 1
Everyone don't work as per their names.
It's name is add_five but it actually adds 6.đđđ
Just like Kushboo naam ki ladki bhi badbu lagti hai đđđđ