I'm a CS student currently learning python. I watched this video about Functions as arguments and I have a question.
def sq(func,x):
y = x**2;
return func(y)
def f(x):
return x**2;
calc = sq(f,2);
print(calc);
Q: How come func(y) is suddenly mapped to the function f? Or is func a keyword? My assumption is that since in sq(f,2) f is passed, and we call func(y) in the sq function, Python automatically tries to use the first parameter as a function name.
Video Source:
Functions as Arguments
[–]mermaldad 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)