0

def test(func, arg): return func(func(arg)) def mult(x): return x * x print(test(mult, 2))

What is the line of processing in this program ?

9th May 2017, 4:52 AM
AJITH KUMAR
AJITH KUMAR - avatar
11 Answers
+ 11
# If you consider: def test(func, arg): return func(func(arg)) def mult(x): return x * x print(test(mult, 2)) """ The output is: - consider only the argument of print() function: - call the test() method with arguments 'mult' function reference and 2 - the test method return the result of func(func(arg)), wich is equivalent to mult(mult(2)) - from inside to outside parenthesis, mult(2) return 4, so next mult(4) return 16 - so the print() function get 16 as argument, so output is: 16 """
9th May 2017, 7:58 AM
visph
visph - avatar
+ 1
The Solution is - 2*2=4 >>> 4*4=16 >>> 16
27th Jan 2020, 6:06 PM
Hakuna Matata
Hakuna Matata - avatar
+ 1
16
18th Apr 2021, 12:00 PM
Osinachi Abraham
+ 1
What is the output of this code? def test(func, arg): return func(func(arg)) def mult(x): return x * x print(test(mult, 2)) output : 16 explanation : 2*2 = 4 ,4*4=16.
28th May 2021, 9:43 AM
Madhavareddy
Madhavareddy - avatar
+ 1
16
9th Oct 2022, 9:04 PM
Kalji
Kalji - avatar
0
The code is not properly indented. Please answer back with the actual working code. https://www.sololearn.com/Discuss/367533/?ref=app
9th May 2017, 5:15 AM
Álvaro
0
What is the output of this code? def test(func, arg): return func(func(arg)) def mult(x): return x * x print(test(mult, 2)) so output is: 16
8th Sep 2019, 10:59 PM
OUSSAMA ROMDHANI
OUSSAMA ROMDHANI - avatar
0
the answer is '16'
6th Aug 2020, 5:39 PM
Michael Yip
Michael Yip - avatar
0
16
28th Dec 2021, 6:24 PM
Thuwayba Ahmed
Thuwayba Ahmed - avatar
- 2
30th Mar 2020, 1:35 PM
KHLIFI SALEH
KHLIFI  SALEH  - avatar
- 2
9th Jun 2020, 2:47 AM
Waled Moumari
Waled Moumari - avatar