Loading

Quipoin Menu

Learn • Practice • Grow

Direction: Choose the correct option

Q1.

What is recursion in Python?
A. A function with multiple returns
B. A loop inside a function
C. A function that calls itself
D. A function that calls another function
Direction: Choose the correct option

Q2.

What is a base case in recursion?
A. The last call of the function
B. A condition that stops the recursion
C. The first call of the function
D. The recursive case
Direction: Choose the correct option

Q3.

What happens if a recursive function has no base case?
A. SyntaxError
B. The function returns None
C. RecursionError (maximum recursion depth exceeded)
D. Infinite loop
Direction: Choose the correct option

Q4.

What is the output of `def fact(n): return 1 if n==0 else n*fact(n-1); print(fact(3))`?
A. 0
B. 6
C. 3
D. 1
Direction: Choose the correct option

Q5.

What does `def count(n): if n<=0: return; print(n); count(n-1); count(3)` print?
A. 3 2 1
B. 3,2,1
C. 1 2 3
D. 3 2 1
Direction: Choose the correct option

Q6.

What is the maximum recursion depth in Python (default)?
A. 500
B. 1000
C. 10000
D. Unlimited
Direction: Choose the correct option

Q7.

Which of the following problems is commonly solved with recursion?
A. All of the above
B. Tree traversal
C. Tower of Hanoi
D. Fibonacci sequence
Direction: Choose the correct option

Q8.

How does recursion compare to iteration in terms of memory?
A. Recursion uses more memory due to call stack
B. Recursion uses less memory
C. Iteration uses more memory
D. They are the same
Direction: Choose the correct option

Q9.

What is tail recursion?
A. A recursive call at the beginning
B. A recursion with multiple calls
C. A recursive call that is the last operation in the function
D. A recursion without base case
Direction: Choose the correct option

Q10.

What is the output of `def f(n): if n==0: return 0; return n + f(n-1); print(f(3))`?
A. 1
B. 3
C. 6
D. 0