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 works on a shorter and shorter slice of a list. What does the program print?
Python ProgrammingHardHigh School (9–10)Python Essentials › RecursionPCEP (Python Institute)
StemPy LabCreated by StemPy Lab

A recursive function works on a shorter and shorter slice of a list. def walk(v): if len(v) == 1: return v return walk(v[1:]) + [v[0]] print(walk([1, 2, 3, 4])) What does the program print?

Log in to save
← All Quizzes
← A function raises an error when it is given an empty list. Three calls are made inside one try block. What does the program print?A function reads from a box, which may be a dictionary, a list or a tuple. Its first except names the family LookupError, and its second names Exception. What does the program print? →
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. Three small functions are defined. Two of them call themselves, and one uses a loop. Which of…Medium
  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 →