Advertisements
Advertisements
Question
Differentiate between the following with the help of an example:
Argument and Parameter
Solution
The parameter is a variable in the declaration of a function. The argument is the actual value of this variable that gets passed to the function when the function is called.
Program:
def create (text, freq):
for i in range (1, freq):
print text
create(5, 4) #function call
Here, in line 1, 'text' and 'freq' are the parameters whereas, in line 4 the values '5' and '4' are the arguments.
APPEARS IN
RELATED QUESTIONS
Observe the following program carefully, and identify the error:
def findValue( vall = 1.1, val2, val3):
final = (val2 + val3)/ vall
print(final)
findvalue() #function call
Assertion (A): If the arguments in function call statement match the number and order of arguments as defined in the function definition, such arguments are called positional arguments.
Reasoning (R): During a function call, the argument list first contains default argument(s) followed by the positional argument(s).
Predict the output of the following code:
def Changer (P, Q=10):
P=P/Q
Q=P%Q
return P
A=200
B=20
A=Changer(A,B)
print(A,B,sep='$')
B=Changer(B)
print(A,B sep='$', end='# # #')