Is "func" arg or keyword | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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???

28th Jun 2021, 2:52 PM
Ritik Mehra
Ritik Mehra - avatar
9 Answers
+ 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...
28th Jun 2021, 7:17 PM
visph
visph - avatar
+ 1
Done ✅
28th Jun 2021, 3:55 PM
Ritik Mehra
Ritik Mehra - avatar
+ 1
nah, func is just a short placeholder name for an arbitruary function. It could be: 'pickles' the name really doesn't matter
28th Jun 2021, 4:39 PM
Slick
Slick - avatar
+ 1
Thanks to everyone, i got my ans ! Great help <3
28th Jun 2021, 7:35 PM
Ritik Mehra
Ritik Mehra - avatar
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?
28th Jun 2021, 3:22 PM
Ritik Mehra
Ritik Mehra - avatar
0
But my question was totally different, no?😹😹 Anyway thank you so much for replying mate❤️
28th Jun 2021, 3:43 PM
Ritik Mehra
Ritik Mehra - avatar
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
28th Jun 2021, 3:54 PM
Solo
Solo - avatar
- 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
28th Jun 2021, 3:37 PM
Solo
Solo - avatar
- 3
code code code
29th Jun 2021, 12:50 AM
Shabas Tech
Shabas Tech - avatar