+ 2
Can you explain please..
2 odpowiedzi
+ 3
First, the add_five function just takes a value and adds 5 to it.
Then, the apply_twice function executes the function provided twice.
If you pass the add_five function to the apply_twice function, func becomes add_five, so it become:
return add_five(add_five(10))
Which simplifies into:
return add_five(15)
And then into:
return 20
Hope this helps.
+ 3
return func(func(arg))
This line is simply replaced with,
return add_five(add_five(10))
So add_five(10) returns 15
Now return add_five(15)
which will return 15+5=20