#Function Definition
def function_name(param1,param2=default_value..):
...
...
return value
Note:
def func(x):
print(f'Address of x is {id(x)}') #1234
x += 10
print(f'Address of x is {id(x)}') #7890 -->Address has changed
a = 10
print(f'Address of a is {id(a)}) #1234
func(a)
print(f'Address of a is {id(a)}) #1234
In summary:
call-by-value because you can not change the value of the immutable objects being passed to the function.call by reference because when their values are changed inside the function, then it will also be reflected outside the function.Keyword Arguments
def function_name(param1,param2):
.....
#Function Call
function_name(param2=value2, param1=value1)
Variable Length Arguments
def func(*args):
if len(args):
for s in args:
print(s)
func('john','mary','aaron')