Amazing technological breakthrough possible @S-Logix pro@slogix.in

Office Address

  • #5, First Floor, 4th Street Dr. Subbarayan Nagar Kodambakkam, Chennai-600 024 Landmark : Samiyar Madam
  • pro@slogix.in
  • +91- 81240 01111

Social List

What is formal arguments in python?

Description

To see the formal arguments in python.

Process
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.

Sample Code

#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’))

Screenshots
What is formal arguments in python Positional arguments are the argumentspassed to a  function in correct positionalorder Keyword arguments are related to thefunction calls variable name  that holds the valuesof all non keyword variable  arguments