# Python Test 7 - Recursion

1. Which is the most appropriate definition for recursion?
Only problems that are recursively defined can be solved using recursion.
Which of these is false about recursion?
Fill in the line of the following Python code for calculating the factorial of a number.
def fact(num): if num == 0:  return 1 else: return _____________________
What will be the output of the following Python code?
def test(i,j): if(i==0): return j else: return test(i-1,i+j) print(test(4,7))
What will be the output of the following Python code?
l=[] def convert(b): if(b==0): return l dig=b%2 l.append(dig) convert(b//2) convert(6) l.reverse() for i in l: print(i,end="")
What is tail recursion?
Observe the following Python code?
def a(n): if n == 0: return 0 else: return n*a(n - 1) def b(n, tot): if n == 0: return tot else: return b(n-2, tot-2)
Which of the following statements is false about recursion?
What will be the output of the following Python code?
def fun(n): if (n > 100): return n - 5 return fun(fun(n+11));  print(fun(45))
Recursion and iteration are the same programming approach.
What happens if the base condition isn’t defined in recursive programs?
Which of these is not true about recursion?
Which of these is not true about recursion?
What will be the output of the following Python code?
def a(n): if n == 0: return 0 elif n == 1: return 1 else: return a(n-1)+a(n-2) for i in range(0,4): print(a(i),end=" ")