Passing Parameters in Functions
Parameters or arguments can be passed to functions
def function_name (parameter(s) separated by comma):
Let us see the use of parameters while defining functions. The parameters that you place in the parenthesis will be used by the function itself. You can pass all sorts of data to the functions. Here is an example program that defines a function that helps to pass parameters into the function.
assume w = 3 and h = 5
return w * h
print (area (3,5))
The above code assigns the width and height values to the parameters w and h. These parameters are used in the creation of the function “area”. When you call the above function, it returns the product of width and height as output.
The value of 3 and 5 are passed to w and h respectively, the function will return 15 as output.
We often use the terms parameters and arguments interchangeably. However, there is a slight difference between them. Parameters are the variables used in the function definition whereas arguments are the values we pass to the function parameters