Arguments and parameters in python CBSE Class 12
ARGUMENTS AND PARAMETERS
As we have seen that we use values to be passed in a function and for this we define variables to receive these values in function definition and these values are sent via a function call statement
for example
def calcsum(x, y):
s = x + y
return s
num1= float(input("Enter first number"))
num2= float(input("Enter second number"))
sum = calcsum (num1,num2)
print("the sum of given numbers is " sum)
Here you see that above program has a function named calcsum that receives two values and when this function is is being called or invoked, the values received by the function are passed to the function body to get the required output according to the functionality of our defined function. Now there are two positions where values and variables play an important role
Number One is, when values are received by variables x and y in function definition.
Number Two, is when these values are passed to the function called for execution.
here comes the concept where you can understand the difference between arguments and parameters.
Arguments -: The moment when values of x and y are passed to the function call for execution the values lets a 2 and 3 are called arguments
Note the value of x and y might be different for given by different users and depends on the imagination that’s why we call these values as arguments (read the concept of imaginary values).
Parameters -: The moment when variable X and Y receive the values for giving at the time of execution x and y are defined in the function header and the exact values are not given to be used then these variables x and y are called parameters
Note – x and y are formally written in function header that indicates that two actual values will come here at the time of execution and these values may be different according the users requirement.
Important -: If you have any confusion between arguments and parameters then you can use the only one term argument for both as
- formal arguments
- actual arguments
Also can use the only term parameter for both as
- formal parameters and
- actual parameters