Explain with a code example the usage of default argument and keyword argument.

Default Argument

 def power(x,y=3):
   for i in range(y):
     r=r*x
   return r
 
 a=intinput((“Enter Base”))
 b=intinput((“Enter Exponent”))
 
 total = power(a,b)
 print(total) 

Usage of Default Argument:
 •Matching arguments are not passed in the function call statementSome argument always have same value. 

Keyword Argument

 def power(x,y):
   for i in range(y):
     r=r*x
   return r
 
 a=intinput((“Enter Base”))
 b=intinput((“Enter Exponent”))
 
 total = power(y=4,x=5)
 print(total) 

Usage:
 •Any argument can be taken or passed in any order during function call. 
error: Content is protected !!