Can anybody explain this? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can anybody explain this?

def add(x, y): return x + y def do_twice(func, x, y): return func(func(x, y), func(x, y)) a = 5 b = 10 print(do_twice(add, a, b))

12th Nov 2019, 11:45 AM
Ave Maria
Ave Maria - avatar
1 Answer
+ 2
1) the first function takes two numbers and return their sum. 2) the second function takes three argument, the first is a function and the other two are numbers. What follows is this... Add(add(5,10) , add(5,10)) Add(15, 15) 30 Hope you get this
12th Nov 2019, 12:12 PM
Fabian Nwobi
Fabian Nwobi - avatar