Functions Questions
Functions Questions
def Add(X,Y):
Z = X+Y
return Z
#statement to call the above function
print(“Total =”,C)
Ans
7 Which Line Number Code will never execute?
def Check(num): #Line 1
if num%2==0: #Line 2
print("Hello") #Line 3
return True #Line 4
print("Bye") #Line 5
else: #Line 6
return False #Line 7
C = Check(20)
print(C)
Ans
8 What will be the output of following code?
def Cube(n):
print(n*n*n)
Cube(n) # n is 10 here
print(Cube(n))
1|Page
Ans
2|Page
9 What are the different types of actual arguments in function? Give example of any
one of them.
Ans
Ans
12 Call the given function using KEYWORD ARGUMENT with values 100 and 200
def Swap(num1,num2):
num1,num2=num2,num1
print(num1,num2)
Swap( , )
Ans
3|Page
13 Which line number of code(s) will not work and why?
def Interest(P,R,T=7):
I=
(P*R*T)/100
print(I)
Interest(20000,.08,15) #Line 1
Interest(T=10,20000,.075) #Line 2
Interest(50000,.07) #Line 3
Interest(P=10000,R=.06,Time=8) #Line 4
Interest(80000,T=10) #Line 5
Ans
4|Page
17 What will be the output of following code?
def check():
global num
num=1000
print(num)
num=100
print(num)
check()
print(num)
Ans
def Alter(M,N=50):
M=M+N
N=M-N
print(M,"@",N)
return M
5|Page
A=200
B=100
A = Alter(A,B)
print(A,"#",B)
B = Alter(B)
print(A,‟@‟,B)
Ans
def Total(Number=10):
Sum=0
for C in range(1,Number+1):
if C%2==0:
continue
Sum+=C
return Sum
print(Total(4))
print(Total(7))
print(Total())
Ans
6|Page
def invoke():
global a
a=500
show()
invoke()
print(a)
Ans
26 What will be the output of following code?
def drawline(char='$',time=5):
print(char*time)
drawline()
drawline('@',10)
drawline(65)
drawline(chr(65))
Ans
7|Page
def Fun2(num1):
num1 = num1 // 2
return num1
n = 120
n = Fun1(n)
print(n)
Ans
29 What will be the output of following code?
X = 50
def Alpha(num1):
global X
num1 += X
X += 20
num1 = Beta(num1)
return num1
def Beta(num1):
global X
num1 += X
X += 10
num1 =
Gamma(num1) return
num1
def Gamma(num1):
X = 200
num1 += X
return num1
num = 100
num = Alpha(num)
print(num,X)
Ans
30 What will be the output of following code?
def Fun1(mylist):
for i in range(len(mylist)):
if mylist[i]%2==0:
mylist[i]/=2
else:
mylist[i]*=2
list1 =[21,20,6,7,9,18,100,50,13]
Fun1(list1)
print(list1)
Ans
8|Page