Help
Contact
For teachers and institutes
Search courses, problems, tests…
A
A
>_
StemPy Lab
Courses ▾
Problems ▾
Practice ▾
Mock Tests
Classes
Groups
Community ▾
A
A
Problems
/
Python Essentials
/
Recursion
Recursion
Python Programming
+ Upload a Problem
More in Python Essentials
Dictionaries
Tuples and Sets
Errors and Exceptions
Modules and Libraries
Searching and Sorting
Recursion
Text Processing
Essentials Projects
All Levels
High School (9–10)
High School (11–12)
Undergraduate
General
All
Easy
Medium
Hard
Sort
Mixed
Newest first
Oldest first
A to Z
17 problems
Type:
Any
Conceptual
Numerical
Python-Coded
1.
A staircase has n steps. You climb one step or two steps at a time.
High School (9–10), High School (11–12), Undergraduate, General · Recursion
StemPy Lab
Medium
2.
Without running anything, say how many subsets there are for lists of 5, 10 and 20 items.
High School (9–10), High School (11–12), Undergraduate, General · Recursion
StemPy Lab
Medium
3.
For each function, say whether a memory (a dictionary of answers) would help, and why.
High School (9–10), High School (11–12), Undergraduate, General · Recursion
StemPy Lab
Easy
4.
Write a recursive function all_positive(items) that gives True if every item of the list is more…
High School (9–10), High School (11–12), Undergraduate, General · Recursion
StemPy Lab
Medium
5.
For each job, say whether a loop or recursion is the better choice, and why.
High School (9–10), High School (11–12), Undergraduate, General · Recursion
StemPy Lab
Easy
6.
For sum_to(3), where sum_to(n) is 0 for n == 0 and n + sum_to(n - 1) otherwise, write the calls…
High School (9–10), High School (11–12), Undergraduate, General · Recursion
StemPy Lab
Medium
7.
What do show_up(3) and show_down(3) print? Say it before you run it.
High School (9–10), High School (11–12), Undergraduate, General · Recursion
StemPy Lab
Easy
8.
Count how many calls the recursive fibonacci(n) makes for n = 5, 10, 15, 20. What do you notice?
High School (9–10), High School (11–12), Undergraduate, General · Recursion
StemPy Lab
Hard
9.
This function never stops, and Python ends it with a RecursionError. Why? Fix it.
High School (9–10), High School (11–12), Undergraduate, General · Recursion
StemPy Lab
Hard
10.
Write count_digits(n) by recursion: a number below 10 has one digit, and any other number has one…
High School (9–10), High School (11–12), Undergraduate, General · Recursion
StemPy Lab
Medium
11.
Write a recursive fibonacci(n). Show the first ten values. What is fibonacci(7)?
High School (9–10), High School (11–12), Undergraduate, General · Recursion
StemPy Lab
Medium
12.
Write is_palindrome(text) by recursion. A text is a palindrome if its first and last letters are…
High School (9–10), High School (11–12), Undergraduate, General · Recursion
StemPy Lab
Hard
13.
Write reverse(text) by recursion. What are reverse("python") and reverse("a")?
High School (9–10), High School (11–12), Undergraduate, General · Recursion
StemPy Lab
Hard
14.
Write power(base, exponent) by recursion, without the ** sign.
High School (9–10), High School (11–12), Undergraduate, General · Recursion
StemPy Lab
Medium
15.
Write a recursive factorial(n). What are factorial(5) and factorial(10)?
High School (9–10), High School (11–12), Undergraduate, General · Recursion
StemPy Lab
Medium
16.
Write sum_to(n) that adds 1 + 2 + … + n by recursion. What are sum_to(5) and sum_to(100)?
High School (9–10), High School (11–12), Undergraduate, General · Recursion
StemPy Lab
Easy
17.
Write a recursive function countdown(n) that shows n, n-1, …, 1 and then Go!
High School (9–10), High School (11–12), Undergraduate, General · Recursion
StemPy Lab
Easy