HelpContactFor teachers and institutes
>_StemPy Lab
Mock TestsClassesGroups

>_StemPy Lab

Learn. Solve. Code the solutions. Test yourself.

Live examsFree mock exams, timed and rankedEveryone starts together, and your score and rank come the moment it ends.See the exams →

Learn

  • Physics
  • Chemistry
  • Mathematics
  • Biology
  • Python Programming
  • Statistics & Data Science
  • Classes
  • Groups

Practice

  • Problems
  • Quizzes
  • Mock Tests
  • Question Sets
  • Exams
  • Certificates
  • Python Labs
  • AI Practice Generator
  • Student-Created Tests

Community

  • Discussions
  • Resources
  • Notes
  • Blog

Account

  • Dashboard
  • My Content
  • Profile
  • Log in
© 2026 senLearn. All rights reserved.HelpAboutContactPrivacy PolicyTerms of UseRefund Policy
  1. Problems
  2. /Python Essentials
  3. /Recursion

Recursion

Python Programming
+ Upload a Problem
More in Python EssentialsDictionariesTuples and SetsErrors and ExceptionsModules and LibrariesSearching and SortingRecursionText ProcessingEssentials Projects
17 problems
Type:
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 · RecursionStemPy LabStemPy 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 · RecursionStemPy LabStemPy 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 · RecursionStemPy LabStemPy 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 · RecursionStemPy LabStemPy 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 · RecursionStemPy LabStemPy 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 · RecursionStemPy LabStemPy 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 · RecursionStemPy LabStemPy 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 · RecursionStemPy LabStemPy 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 · RecursionStemPy LabStemPy 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 · RecursionStemPy LabStemPy 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 · RecursionStemPy LabStemPy 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 · RecursionStemPy LabStemPy 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 · RecursionStemPy LabStemPy Lab
Hard
14.
Write power(base, exponent) by recursion, without the ** sign.
High School (9–10), High School (11–12), Undergraduate, General · RecursionStemPy LabStemPy 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 · RecursionStemPy LabStemPy 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 · RecursionStemPy LabStemPy 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 · RecursionStemPy LabStemPy Lab
Easy