0
can anyone 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))
1 ответ
0
firstly you call do_twice function
it takes as argument a function and two int numbers
it calls the function in the argument (add in this case) with arguments the function (add) with argument x and y (take in this case are a and b)
#it works like this
print(do_twice(add,a,b))
#in do_twice it happens
return add(add(a,b), add(a,b))
#having done add(a,b) it does
#add(15,15), that is 30, so it prints 30