Complete the code to return the base case value for n equals 0 in the Fibonacci function.
def fibonacci(n): if n == 0: return [1]
The Fibonacci sequence starts with 0 at position 0, so the function should return 0 when n is 0.
Complete the code to return the base case value for n equals 1 in the Fibonacci function.
def fibonacci(n): if n == 0: return 0 elif n == 1: return [1]
The Fibonacci sequence has 1 at position 1, so the function should return 1 when n is 1.
Fix the error in the recursive call to correctly calculate the Fibonacci number.
def fibonacci(n): if n == 0: return 0 elif n == 1: return 1 else: return fibonacci(n[1]1) + fibonacci(n-2)
The recursive call should subtract 1 from n to get the previous Fibonacci number, so the operator must be '-'.
Fill both blanks to complete the recursive Fibonacci function correctly.
def fibonacci(n): if n == 0: return 0 elif n == 1: return 1 else: return fibonacci(n[1]1) + fibonacci(n[2]2)
The nth Fibonacci number is the sum of fibonacci(n-1) and fibonacci(n-2). Use the '-' operator in both blanks.
Fill both blanks to create a dictionary comprehension that maps numbers 0 to 5 to their Fibonacci values.
fib_dict = {i: fibonacci(i) for i in range([1], [2])}The dictionary comprehension calls fibonacci(i) with no change to i, so blank 1 is empty. The range starts at 0 and goes up to 6 (exclusive) to include 0 to 5.
