0

Functions as a object

Could someone explain this code? how its work 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))

3rd Oct 2018, 10:48 AM
Shahinur Rahman
Shahinur Rahman - avatar
1 ответ
0
do_twice(add,5,10) => add( add(5,10) , add(5,10) ) => add( 5+10 , 5+10 ) => add( 15 , 15 ) => 15+15 => 30
3rd Oct 2018, 12:22 PM
Gordon
Gordon - avatar