+ 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))

30th Jan 2018, 4:09 AM
Aniket Mane
Aniket Mane - avatar
3 Answers
+ 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 šŸ˜Š"""
30th Jan 2018, 4:48 AM
šŸŒ›DTšŸŒœ
šŸŒ›DTšŸŒœ - avatar
+ 3
Ya tnx that explains it allšŸ‘ŒšŸ‘Œ
30th Jan 2018, 5:56 AM
Aniket Mane
Aniket Mane - avatar
+ 1
take a look at this code. it might help you to understand. https://code.sololearn.com/chiIX2rD1cIo/?ref=app
30th Jan 2018, 5:57 AM
davy hermans
davy hermans - avatar