0

How to find output in program. I'm not understand twice function in this code

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))

19th Dec 2019, 3:38 AM
Vikram Singh
Vikram Singh - avatar
2 Answers
+ 3
I have put some information and explanation for you together with the extended code from you. Hope this helps. Don't worry if you get a little bit confused of this code, but you will very rarely find something like this in practice. It's more a demonstration what's possible. In general this kind of functional programming is used very offen, but in a more clear and readable way. https://code.sololearn.com/cXJst991RZ7e/?ref=app https://code.sololearn.com/cXJst991RZ7e/?ref=app
19th Dec 2019, 6:55 AM
Lothar
Lothar - avatar