+ 3
What does *num stands for or what it does in given code
a=3 def sumofnum(*num): return sum(num) print(sumofnum(a,a**a,a*4))
3 Respuestas
+ 21
(*num) is kind of optional parameter...
it takes any number of arguments passed to the function....
that code will output :- 42
as it will take all three arguments passed and will sum it up...
a+a**a+a*4 = 3+3**3+3*4 = 3+27+12 = 42
Consider 1 more eg.:-
a=3
def fun(n,*num) :
return something
print (fun(1,2,3,4,5))
"""now here n is mandatory parameter & num is optional so 1 will be passed to n & rest will be passed to num...
i hope this helps 😊"""
+ 3
Ya tnx that explains it all👌👌
+ 1
take a look at this code. it might help you to understand.
https://code.sololearn.com/chiIX2rD1cIo/?ref=app