*args and *kwargs in python code example

Example 1: use of kwargs and args in python classes

def myFun(*args,**kwargs): 
    print("args: ", args) 
    print("kwargs: ", kwargs) 
    
myFun('my','name','is Maheep',firstname="Maheep",lastname="Chaudhary")

# *args - take the any number of argument as values from the user 
# **kwargs - take any number of arguments as key as keywords with 
# value associated with them

Example 2: python *arg **kwargs

>>> def f(a, b, *args, **kwargs):
...     print(F'a = {a}')
...     print(F'b = {b}')
...     print(F'args = {args}')
...     print(F'kwargs = {kwargs}')
...

>>> f(1, 2, 'foo', 'bar', 'baz', 'qux', x=100, y=200, z=300)
a = 1
b = 2
args = ('foo', 'bar', 'baz', 'qux')
kwargs = {'x': 100, 'y': 200, 'z': 300}