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. /Three small functions are defined. Two of them call themselves, and one uses a loop. Which of these expressions are True? Choose every correct option.
Python ProgrammingMediumHigh School (9–10)Python Essentials › RecursionPCEP (Python Institute)
StemPy LabCreated by StemPy Lab

Three small functions are defined. Two of them call themselves, and one uses a loop. def a(n): if n == 0: return 0 return n + a(n - 1) def b(n): total = 0 for k in range(n): total += k return total def d(n): if n <= 1: return n return n * d(n - 1) Which of these expressions are True? Choose every correct option.

One or more options are correct. Tick all the correct ones: a wrong option costs marks, and a part-right answer earns part of the marks.

Log in to save
← All Quizzes
← One function calls another. The inner one reads past the end of a list, and neither function has a try. What does the program print?Two functions share a global variable. The first call is made before the variable exists, inside a try statement. What happens when the program runs? →
More onPython Essentials › Recursion

Discussion (0)

Log in to join the discussion.

Loading…

More questions on this topic

  1. A recursive function calls itself twice for each number that is two or more, and adds one each…Hard
  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 →