0
Is "func" arg or keyword
def apply_twice(func, arg): return func(func(arg)) def add_five(x): return x + 5 print(apply_twice(add_five, 10)) Is func a keyword or is it argument to execute add_five function???
9 Réponses
+ 2
'func' is an arbitrary argument name... so 'func' is an argument, not a builtin keyword...
arguments are special kind of variable used as placeholder to pass values (may be functions) to a function execution body...
+ 1
Done ✅
+ 1
nah, func is just a short placeholder name for an arbitruary function. It could be: 'pickles' the name really doesn't matter
+ 1
Thanks to everyone, i got my ans ! Great help <3
0
I know the answer i just want to know that 'func' passed as a argument and the by python it treated as a function keyword?
0
But my question was totally different, no?😹😹 Anyway thank you so much for replying mate❤️
0
your question was to explain how the func function works, I gave you my explanations from which you could understand that there is no func keyword in Python, you can rename it to any other for example arg1
- 1
apply_twice(add_five, 10 ) =>
=> return add_five(add_five(10)) =>
=> add_five(10) # return 15
add_five(15) # return 20
func is an argument of the apply_twice function to which the add_five function is assigned with an argument x to which the add_five function is assigned with an argument value of 10
- 3
code code code