Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis0
I s func a keyword?
how does apply twice function know that func is a function. ? confusing a lot.
2 Respostas
0
No, func isn't a keyword. Since functions are just objects, you can give it by arguments, make a list of them... Maybe this can help to understand:
>>> lst = [lambda x:x**2, lambda x:x**3, lambda x: x**4]
>>> lst[0](4)
16
>>> lst[1](4)
64
>>> lst[2](4)
256
apply_twice doesn't know about it's argument's type. This function just takes an argument and tries to call it.
0
func is an argument, just like a and b. the example could have used any variable name instead