Here we a going to define a function which carries some parameters.
Here as in the previous program, we define functions.
But here some variables are passed as parameters.
Look at the code snippet:
def addd(a,b): c=a+b return(c)
Here we have defined a function ‘addd’.
This function uses the value of the parameters ‘x‘ and ‘y‘, when it is being executed.
The values passed into the function at the time of function call into the variables ‘a‘ and ‘b‘, in the same order as they are written in the function call
This means value of ‘x‘ is copied into ‘a‘ and the value of ‘y‘ is copied into ‘b‘.
And further the execution of the statements in the function definition are carried out using these values.
Now when we look into rest of the code,
There we have just entered integer values into variables ‘x‘ and ‘y‘ using ‘input‘ function.
After that we called the ‘addd(x,y)‘ function.
Then after the execution of the function is complete, the value stored in the variable ‘c‘ is returned to the variable ‘d‘, using the return statement, in the function definition.
After the function has returned the value, which is the sum of two numbers in our program, it is printed using the ‘print‘ function.