Default Parameters
Default Parameters
my_function("Sweden")
my_function("India")
my_function()
my_function("Brazil")
output:
I am from Sweden
I am from India
I am from Norway
I am from Brazil
Keyword Arguments: Parameter Names are used to pass the argument during the
function call. Order of parameter Names can be changed to pass the argument(or values).
def nameAge(name, age):
print("Hi, I am", name)
print("My age is ", age)
nameAge(name="Prince", age=20)
nameAge(age=20, name="Prince")
Output
Hi, I am Prince
My age is 20
Hi, I am Prince
My age is 20
Positional Arguments: Arguments are passed in the order of parameters. The order
defined in the order function declaration. Order of values cannot be changed to avoid
the unexpected output.
During a function call, values passed through arguments should be in the order of parameters in the
function definition.
Case-2:
Hi, I am 20
My age is Prince