Types of Arguments
5 tips for a simpler way to work
Types of Arguments
1. Default arguments:
 Default arguments are values that are provided while defining functions.
 The assignment operator = is used to assign a default value to the argument.
 Default arguments become optional during the function calls.
 If we provide a value to the default arguments during function calls, it overrides
the default value.
 The function can have any number of default arguments
 Default arguments should follow non-default arguments.
Example : Default Arguments
1. Default arguments:
def add(a,b=5,c=10):
return (a+b+c)
n=10
print(add(n))
 .
Example : Default Arguments
Default arguments:
def add(a,b=5,c=10):
return (a+b+c)
n=10
print(add(n))
 .
It can be called in 3 ways:
print(add(3))
#Output:18
print(add(3,4))
#Output:17
print(add(2,3,4))
#Output:9

Types of Arguments in Python.pptx

  • 1.
    Types of Arguments 5tips for a simpler way to work
  • 2.
    Types of Arguments 1.Default arguments:  Default arguments are values that are provided while defining functions.  The assignment operator = is used to assign a default value to the argument.  Default arguments become optional during the function calls.  If we provide a value to the default arguments during function calls, it overrides the default value.  The function can have any number of default arguments  Default arguments should follow non-default arguments.
  • 3.
    Example : DefaultArguments 1. Default arguments: def add(a,b=5,c=10): return (a+b+c) n=10 print(add(n))  .
  • 4.
    Example : DefaultArguments Default arguments: def add(a,b=5,c=10): return (a+b+c) n=10 print(add(n))  . It can be called in 3 ways: print(add(3)) #Output:18 print(add(3,4)) #Output:17 print(add(2,3,4)) #Output:9