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 calls itself twice for each number that is two or more, and adds one each time. 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 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?
5
7
4
9
Check Answer
Log in to save
Tag someone
⚑ Report
← 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 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 →