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 ?
11 Réponses
+ 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
"""
+ 1
The Solution is - 2*2=4 >>> 4*4=16
>>> 16
+ 1
16
+ 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.
+ 1
16
0
The code is not properly indented. Please answer back with the actual working code.
https://www.sololearn.com/Discuss/367533/?ref=app
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
0
the answer is
'16'
0
16
- 2
- 2