Keyword / Named Arguments in Function


☞Keyword arguments are the name arguments with assigned values being passed in the function call statement.

Example :

def add(a,b):
    c=a+b
    print(c)

#__main__
add(a=10, b=20)      #a and b are Keyword Arguments
add(b=10, a=20)      #b and a are Keyword Arguments
add(10,b=20)         #a is Positional Argument and b is Keyword Argument
NOTE :- You cannot perform following operations during function calling.
☞add(a=10, 20)	      #SyntaxError : positional argument follows keyword argument
☞add(10, a=20)	      #TypeError : add() got multiple values for argument ‘a’
☞add(a=10, a=20)     #SyntaxError : keyword argument repeated