What is formal arguments in python?

Description

To see the formal arguments in python.

Positional
  • Positional arguments are the argumentspassed to a  function in correct positionalorder.
  • The number of arguments in the functioncall  should match exactly with thefunction definition.

Keyword

  • Keyword arguments are related to thefunction calls.
  • When you use keyword arguments in afunction  call, the caller identifies thearguments by the  parameter name.

Default

  • A default argument is an argument thatassumes a  default value if a value isnot provided in the function  call forthat argument.

Variable length

  • An asterisk (*) is placed before thevariable name  that holds the valuesof all non keyword variable  arguments.

#Positional arguments

def city(str1,str2):

str3=str1+str2

return str3

print(“*************Positional arguments output\n”)

print(city(“Tamil”,”Nadu”))

#keyword arguments

def employee(name=”sathish”,

salary=5000):return name,salary

print(“*************keyword arguments output\n”)

print(employee(salary=8000

,name=”kumar”))

#default arguments

def points(x=10,y=5,z=7):

return x,y,z

print(“*************default arguments output\n”)

print(points(10,2,3))

print(points(2,10,1))

print(points(2,3))

print(points(x=5,y=4))

#Variable length arguments

def varlength(*names):

return names

print(“*************variable length arguments output\n”)

print(varlength(‘sathish’,’sangeetha’,

‘sudakar’,’balachandar’))

Leave Comment

Your email address will not be published. Required fields are marked *

clear formSubmit