Help
Contact
For teachers and institutes
Search courses, problems, tests…
A
A
>_
StemPy Lab
Courses ▾
Problems ▾
Practice ▾
Mock Tests
Classes
Community ▾
A
A
Quizzes
/
A recursive function works on a shorter and shorter slice of a list. What does the program print?
Python Programming
Hard
High School (9–10)
Python Essentials › Recursion
PCEP (Python Institute)
Created by
StemPy Lab
Stuck? Show a hint
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?
It stops with
RecursionError
[4, 3, 2, 1]
[1, 2, 3, 4]
[4]
Check Answer
Log in to save
Tag someone
⚑ Report
← 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 on
Python Essentials › Recursion
Discussion (0)
Log in
to join the discussion.
Loading…
All questions on this topic →
Problems on this topic
A staircase has n steps. You climb one step or two steps at a time…
Medium
Without running anything, say how many subsets there are for lists of 5, 10 and 20 items…
Medium
For each function, say whether a memory (a dictionary of answers) would help, and why…
Easy
Write a recursive function all_positive(items) that gives True if every item of the list is more…
Medium
All problems on this topic →