In: Computer Science
Practice: Look at the following function header:
def foo(a, b, c, d, e)
answer the following questions:
Below is the answer of all of your questions :
a.) Five parameters (a,b,c,d,e)
Explanation : Syntax of python function is def nameoffunction( single or multiple parameter seperated by ,):
So in your function def foo(a, b, c, d, e) , a b c d and e are five parameters.
b.) foo
Explanation : Syntax of python function is def nameoffunction( single or multiple parameter seperated by ,):
So in your function def foo(a, b, c, d, e) , foo is the name of this function .
c.) a = 3 , b = 2, c = 3 , d = c , e = Wdu
Explanation : Values are assign according to order of parameter. So 3 is assign to a , 2 is assign to b , 1 is assign to c, c is assign to d and Wdu is assign to e. Below is the screenshot of values assignment :
e.) a = int , b = int , c = int , d = str , e = str
Explanation : 3 2 and 1 are int. c and Wdu are str. Single and double have no difference in python and both are considered as string. Below is the screenshot of data types assign to variable.
You can check your answers of c and d by using following code :
def foo(a, b, c, d, e):
print ("a =", a, type(a))
print ("b =", b, type(b))
print ("c =", c, type(c))
print ("d =", d, type(d))
print ("e =", e, type(e))
return;
# Now you can call sum function
foo( 3, 2, 1, 'c', "wdu");