How the variable "func" take the function "square"? Thanks | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How the variable "func" take the function "square"? Thanks

27th Sep 2016, 7:38 PM
Giorgio Dodesini
Giorgio Dodesini - avatar
6 Answers
+ 4
It was passed as parameter in print(test(square,42)). Is that question because you aren't used to manipulate functions as if they were just another variable, or is it because you aren't used to passing variables with different names than the parameters of the function?
27th Sep 2016, 8:30 PM
Zen
Zen - avatar
+ 1
Please post the code as well.
27th Sep 2016, 7:53 PM
Zen
Zen - avatar
0
For example: def square(x): return x * x def test(func,x): return func(x) print(test(square,42)) How "func" take the function "square"?
27th Sep 2016, 8:11 PM
Giorgio Dodesini
Giorgio Dodesini - avatar
0
I think because i'm not used to passing variables with different names than parameter of the function, when i saw this funcion in the "lesson" I just asked myself the reason. Thanks for helping me.
27th Sep 2016, 8:53 PM
Giorgio Dodesini
Giorgio Dodesini - avatar
0
hi
27th Sep 2016, 10:26 PM
QUINCY LASSETER
QUINCY LASSETER - avatar
0
I'm knew here can you help me please
27th Sep 2016, 10:27 PM
QUINCY LASSETER
QUINCY LASSETER - avatar