HelpContactFor teachers and institutes
>_StemPy Lab
Mock TestsClasses

>_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 →
Live examsInternational live exams are comingTell us which exam you want first. Timed practice papers are open now.See what is coming →

Learn

  • Physics
  • Chemistry
  • Mathematics
  • Biology
  • Python Programming
  • Statistics & Data Science
  • Computer Science
  • Space Science and Astronomy
  • Earth and Environmental Science
  • Classes
  • Groups

Practice

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

Community

  • Discussions
  • Resources
  • Notes
  • Glossary
  • Blog

Account

  • Log in
© 2026 senLearn. All rights reserved.HelpFor SchoolsAboutContactPrivacy PolicyTerms of UseRefund Policy
  1. Quizzes
  2. /A recursive function calls itself twice for each number that is two or more, and adds one each time. What does the program print?
Python ProgrammingHardHigh School (9–10)Python Essentials › RecursionPCEP (Python Institute)
StemPy LabCreated by StemPy Lab

A recursive function calls itself twice for each number that is two or more, and adds one each time. def calls(n): if n < 2: return 1 return calls(n - 1) + calls(n - 2) + 1 print(calls(4)) What does the program print?

Log in to save
← All Quizzes
← A function adds results to a list that it is given. Part way through, one of the results fails, and the caller handles the error. What does the program print?Next →
More onPython Essentials › Recursion

Discussion (0)

Log in to join the discussion.

Loading…

More questions on this topic

  1. Three small functions are defined. Two of them call themselves, and one uses a loop. Which of…Medium
  2. A recursive function works on a shorter and shorter slice of a list. What does the program print?Hard
  3. The function mirror moves the last letter of a text to the front and the first letter to the back…Hard
  4. A function counts calls to itself, and its only way out is a test for exactly zero. What is the…Hard
  5. A function multiplies its argument by its own result for a number two smaller, and stops at one or…Hard
All questions on this topic →

Problems on this topic

  1. A staircase has n steps. You climb one step or two steps at a time…Medium
  2. Without running anything, say how many subsets there are for lists of 5, 10 and 20 items…Medium
  3. For each function, say whether a memory (a dictionary of answers) would help, and why…Easy
  4. Write a recursive function all_positive(items) that gives True if every item of the list is more…Medium
All problems on this topic →