0

Can someone explain this function within functiong thing

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 Jun 2020, 5:43 AM
Abhay Vishwakarma
Abhay Vishwakarma - avatar
2 ответов
+ 1
By making func add what it's now reading is: Return add(a+b,a+b) Everywhere you use the word func, has become add.
12th Jun 2020, 6:46 AM
Olivia
Olivia - avatar
- 1
u r calling the function pointer with given parameters, first the most inner calls are made, then u get to make the last outter call.
12th Jun 2020, 5:54 AM
Flash