Function Output: What will the output of the following program be?

Code

def addn(*args):
      return(sum(args))
print(addn(1,2,3,4))
print(addn(5,6))

Option 1:

10
11

Option 2:
10
Error

Option 3:
Error
11

Option 4:

Error

The ‘*args’ argument passed to the function allows the function to take any number of arguments. Hence, the function is able to compute the sum of the arguments provided to the function both the times and does not throw an error.

Comments