Complete the code to make the recursive function call itself with a smaller number.
def countdown(n): if n <= 0: print("Blastoff!") else: print(n) countdown([1])
The function calls itself with n - 1 to count down towards zero.
Complete the code to return the factorial of n using recursion.
def factorial(n): if n == 0: return 1 else: return n * factorial([1])
The factorial of n is n times factorial of n minus 1.
Fix the error in the recursive Fibonacci function call.
def fibonacci(n): if n <= 1: return n else: return fibonacci([1]) + fibonacci(n - 2)
The Fibonacci function calls itself with n - 1 and n - 2 to sum the two previous numbers.
Fill both blanks to complete the recursive sum of a list.
def recursive_sum(lst): if not lst: return 0 else: return lst[[1]] + recursive_sum(lst[[2]:])
The function adds the first element (index 0) to the sum of the rest of the list starting from index 1.
Fill all three blanks to create a recursive function that reverses a string.
def reverse_string(s): if len(s) == [1]: return s else: return s[[2]] + reverse_string(s[[3]:])
The base case is when the string length is 1. The function takes the last character (index -1) and adds the reverse of the rest (from start to before last).
