Functions - Type B Questions
Functions - Type B Questions
Functions - Type B Questions
(b)
Answer =
(i) In line 3 & 4 there should be double indentation.
total = 0
def sum( arg1, arg2 ):
total = arg1 + arg2
print("Total :", total)
return total
sum( 10, 20 )
print("Total :", total)
Output:-
Total : 30
Total : 0
(ii) In line 5 "RETURN" should be in small words and also there is only one indentation.
Output:-
6
21
Q. Consider the following code and write the flow of execution for this. Line numbers
have been given for your reference.
def power (b, p): #1
y = b ** p #2
return y #3
#4
def calcSquare(x): #5
a = power (x, 2) #6
return a #7
#8
n=5 #9
result = calcSquare(n) # 10
print (result) # 11
Answer :-
1->5->9->10->5->6->1->2->3->6->7->10->11
Output :-
25
Answer =
It is a void function.
So, it will return None.
Answer =
When function called then it will add all the argument and it will show nothing.
(i)
num = 1
def myfunc ():
return num
print(num)
print(myfunc())
print(num)
(ii)
num = 1
def myfunc():
num = 10
return num
print (num)
print(myfunc())
print(num)
(iii)
num = 1
def myfunc ():
global num
num = 10
return num
print (num)
print(myfunc())
print(num)
(iv)
def display():
print("Hello", end = ' ')
display()
print("there!")
Answer =
(i)
Output:-
1
1
1
>>>
(ii)
Output:-
1
10
1
(iii)
Output:-
1
10
10
(iv)
Output:-
Hello there!