0
Functions
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)) Result: >>> 30 >>> Guys can you explain me please how does this exercise work? I cannot understand it at all. What is the role of argument "func"? And how does the second return work. how do we get 30? Somebody explain me please!
2 ответов
+ 3
https://www.sololearn.com/Discuss/1505603/i-don-t-understand-this-code-somebody-help-me
https://www.sololearn.com/Discuss/41733/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
https://www.sololearn.com/Discuss/577175/can-anyone-explain-this
https://www.sololearn.com/Discuss/478557/functions-as-objects
https://www.sololearn.com/Discuss/268/what-exactly-is-the-point-of-assigning-a-function-to-a-variable
https://www.sololearn.com/Discuss/1316935/welcome-to-sololearn-forum/
0
Thank you Anna :)