``````

In [1]:

def my_sum(*args):
return sum(args)

``````
``````

In [2]:

print(my_sum(1, 2, 3, 4))

``````
``````

10

``````
``````

In [3]:

print(my_sum(1, 2, 3, 4, 5, 6, 7, 8))

``````
``````

36

``````
``````

In [4]:

def my_sum2(*args):
print('args: ', args)
print('type: ', type(args))
print('sum : ', sum(args))

``````
``````

In [5]:

my_sum2(1, 2, 3, 4)

``````
``````

args:  (1, 2, 3, 4)
type:  <class 'tuple'>
sum :  10

``````
``````

In [6]:

def func_args(arg1, arg2, *args):
print('arg1: ', arg1)
print('arg2: ', arg2)
print('args: ', args)

``````
``````

In [7]:

func_args(0, 1, 2, 3, 4)

``````
``````

arg1:  0
arg2:  1
args:  (2, 3, 4)

``````
``````

In [8]:

func_args(0, 1)

``````
``````

arg1:  0
arg2:  1
args:  ()

``````
``````

In [9]:

def func_args2(arg1, *args, arg2):
print('arg1: ', arg1)
print('arg2: ', arg2)
print('args: ', args)

``````
``````

In [10]:

# func_args2(0, 1, 2, 3, 4)
# TypeError: func_args2() missing 1 required keyword-only argument: 'arg2'

``````
``````

In [11]:

func_args2(0, 1, 2, 3, arg2=4)

``````
``````

arg1:  0
arg2:  4
args:  (1, 2, 3)

``````
``````

In [12]:

def func_args_kw_only(arg1, *, arg2):
print('arg1: ', arg1)
print('arg2: ', arg2)

``````
``````

In [13]:

# func_args_kw_only(100, 200)
# TypeError: func_args_kw_only() takes 1 positional argument but 2 were given

``````
``````

In [14]:

func_args_kw_only(100, arg2=200)

``````
``````

arg1:  100
arg2:  200

``````