Parameters are variables, used in a function which are provided as input to function when called
The behaviour of a function can depend on the parameters accepted by it
A function might be defined with one or more parameters
Function parameters are the names listed in the function definition
Function arguments(or actual parameters are the real values passed to (and received by) the function when executed
For example
def square(x):
x
In the above example, x is a parameter
And when the function is called with a value such as square(12)
then the value 12
is the argument
Also in the case
a = 15
square(a)
a
is the argument
In strongly typed language such as Java, the data type of a parameter has to be specified during function definition
In a dynamically typed language type of a variable is determined during run time
In Python, which is a dynamically typed language, data types are associated with the values, and the variables only act as reference to the value
Parameters can be categorised based on whether the value is passed to the function or a reference to the (memory address of the) object or value is passed
In call by value, the argument is evaluated, and the resulting value is bound to the corresponding variable in the function (typically by copying the value to new memory)
In call by reference, the argument variable supplied by the caller is a reference to its value(in memory) and any changedone to the corresponding parameter of the function is reflected in the argument supplied