0

How this produce 30 output

def add(x, y): print("abc") 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))

19th Nov 2018, 1:43 PM
Nitin Malik
Nitin Malik - avatar
3 Respostas
+ 5
first it produce two 15 and then add them
19th Nov 2018, 1:55 PM
Madhav
Madhav - avatar
+ 5
return func(func(x,y),func(x,y)) first it adds x and y twice so now arguments are add(15,15) i.e you are saying add(add(5,10),add(5,10)) that becomes add(15,15)
19th Nov 2018, 1:59 PM
Madhav
Madhav - avatar
+ 1
why this code adding 15,15 argument
19th Nov 2018, 1:57 PM
Nitin Malik
Nitin Malik - avatar