What is the output explain with reason | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the output explain with reason

def Foo(n): def multiplier(x): return x*n return multiplier a = Foo(4) b = Foo(4) print(a(b(5)))

14th Jun 2020, 11:35 AM
Vikas Mishra
Vikas Mishra - avatar
1 Answer
+ 2
The function Foo returns the function multiplier which is assigned to a. Now for example if you say a(5), it will go to the function Foo and inside it will execute the multiplier function with a value 5. Since n was 4 already, it would return 5*4=20. In your case b(5) is 20 like explained above and then a(20) will give 4*20=80.
14th Jun 2020, 12:01 PM
Avinesh
Avinesh - avatar