Q. Carefully go through the following sample code and identify various parts of functions.
(a)
def sub1(a, b):
print (b, "-", a, " = ", b - a)
(b)
def cube2(x):
x*x*x
return x*x*x-x
(c)
def cube1(x):
return x*x*x
(d)
def greeting():
print("Welcome to Python")
Answer :-
(a)
Function Name | sub1 |
Takes any argument? If yes, their names | arguments are ‘a’, ‘b’. |
Number of statements in the function-body | One |
Returns any value? | Yes, it returns value after solving values of variable ‘a’ and ‘b’. |
What is it doing? (Carefully read the code and write a line about its functionality) | It prints data which is passes in print statement. |
(b)
Function Name | cube2 |
Takes any argument? If yes, their names | arguments are ‘x’. |
Number of statements in the function-body | Two |
Returns any value? | Yes |
What is it doing? (Carefully read the code and write a line about its functionality) | It solves expression which is in the function. |
(c)
Function Name | cube1 |
Takes any argument? If yes, their names | arguments are ‘x’. |
Number of statements in the function-body | One |
Returns any value? | Yes |
What is it doing? (Carefully read the code and write a line about its functionality) | It solves expression which is in the function. |
(d)
Function Name | greeting |
Takes any argument? If yes, their names | No |
Number of statements in the function-body | One |
Returns any value? | Yes |
What is it doing? (Carefully read the code and write a line about its functionality) | It prints data which is passes in print statement. |
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )