Loading, please wait...

A to Z Full Forms and Acronyms

What are Function Arguments in Python | Python Tutorials

Jun 24, 2021 Python, 2505 Views
Function Arguments in Python | Python Tutorials

What are Function Arguments in Python | Python Tutorials

It is great to know that in the Python Programming language, one can call a function using the following :

  • Keyword-Arguments
  • Variable Length-Arguments
  • Required-Arguments
  • Default-Arguments

Keyword-Arguments

When a user uses the keyword arguments during a function, it identifies the arguments by the parameter.

def name( input ):
   print input
   return;
name( input = "Rajib Kr Jha")

Variable Length-Arguments

Variable Length-Arguments process a function for more arguments than specified.

def passarg( argmt, *vartuple ):
   print "Result: "
   print argmt
   for variable in vartuple:
      print variable
   return;
passarg( 25 )
passarg( 35, 55, 90 )

Required Arguments

These are the arguments that are passed in the correct order, the number of arguments should match exactly the function defined.

def thisoneprint( name ):
   print name
   return;
thisoneprint()

Default Arguments

This is an argument that selects a default value if the value is not provided in the function call.

def information( name, salary = 45000 ):
   print "Name: ", name
   print "Salary ", salary
   return;
information( salary=50000, name="Rohan" )
information( name="Rohan" )

 

A to Z Full Forms and Acronyms

Related Article