<jupyter_start><jupyter_text>More *args & **kwargs(Taken from Youtube 'Optional Arguments in pythin With *args and **kwargs')<jupyter_code>#defining a function called ‘theMatrix’ - one argument and extra positionaal arguments
#positonal argument and a keyword argument

def theMatrix(required, *args, **kwargs):

    #print required parameters and arguments

    print(required)
    if args:
        print(args)
    if kwargs:
        print(kwargs)

#printing with a single paramenter
theMatrix('hello')

#printing with a single paramenter and argument
theMatrix('hello', 10,45,69,98,17,28)
#printing with a single paramenter, argument and keyword arguments
theMatrix('hello', 10,45,69,98,17,28, key1='date',key2=280816)
#results in a single variable, tuples and the extra keyword arguments in a dictionary.
#The stored values can now be used by functions.<jupyter_output><empty_output><jupyter_text>Writing Wrapper Functions - Examples<jupyter_code>#wrapping allows you to make some changes to the arguments 
#that you are passing in before calling the original function.

def theMatrix(x,*args,**kwargs):
    #mutation, name key added to 'keyword Args'
    kwargs['name'] = 'Trinity'
    newArgs = args + ('extra', )
    bar(x, *new_args, **kwargs)
#
class Car:
    def __init__(self, colour, mileage):
        self.colour = colour
        self.mileage = mileage
#
class alwaysNewCar(Car):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.colour = 'Matte Black'<jupyter_output><empty_output><jupyter_text>(Taken from Youtube '*Args and **Kwargs With Multiple Examples'<jupyter_code>def add(*args):
    my_sum = 0
    for arg in args:
        try:
            arg = int (arg)
            my_sum += arg
        except ValueError:
            continue
    return my_sum
add(4,5)
add(4,5,66,54)<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup