Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Recursion

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.
Which statement about recursion in Python is TRUE?
a)
Every recursive function must have a base case to prevent infinite recursion
b)
Recursion always runs faster than iteration
c)
Python has no limit on recursion depth
d)
Recursive functions cannot return values
2.

What will this code print?

a)
3
b)
6
c)
9
d)
Error
3.
What happens if a recursive function has no base case?
a)
It will run faster
b)
It will return None
c)
It will cause a RecursionError
d)
It will exit after one call
4.

Output?

a)
10
b)
6
c)
1234
d)
Error
5.
Which of the following is NOT a good use of recursion?
a)
Tree traversal
b)
Factorial calculation
c)
Processing very large loops without a base case
d)
Fibonacci number calculation
6.

What is the output?

a)
2
b)
3
c)
5
d)
4
7.
In Python, the default recursion depth limit can be checked using:
a)
sys.getrecursionlimit()
b)
recursion.limit()
c)
get.limit()
d)
sys.limit()
8.
What is tail recursion?
a)
A recursive call that appears at the start of a function
b)
A recursive call that appears at the end of a function with no further computation
c)
Recursion that uses a tail data structure
d)
Recursion that calls multiple functions
9.

What is printed?

a)
9
b)
12
c)
6
d)
15
10.
Which scenario is most suitable for recursion?
a)
Finding factorial of a small number
b)
Iterating over a list with millions of elements
c)
Computing the sum of two numbers
d)
Printing 'Hello' 5 times