6.
Which of these is false about recursion?
a)Recursive function can be replaced by a non-recursive function
b)Recursive functions usually take more memory space than non-recursive function
c)Recursive functions run faster than non-recursive function
d)Recursion makes programs easier to understand
7.
Fill in the line of code for calculating the factorial of a number.
def fact(num): if num == 0: return 1 else: return _____________________
a)num*fact(num-1)
b)(num-1)*(num-2)
c)num*(num-1)
d)fact(num)*fact(num-1)
8.
What is the output of the following piece of code?
def test(i,j): if(i==0): return j else: return test(i-1,i+j) print(test(4,7))
a)13
b)7
c)Infinite loop
d)17
(check)
9.
What is the output of the following piece of code?
def fun(n): if (n > 100): return n - 5 return fun(fun(n+11)); print(fun(45))
a)50
b)100
c)74
d)Infinite loop
10.
What happens if the base condition isn’t defined in recursive programs?
a)Program gets into an infinite loop
b)Program runs once
c)Program runs n number of times where n is the argument given to the function
d)An exception is thrown