Complete the code to return 1 when n is 0.
def factorial(n): if n == [1]: return 1 else: return n * factorial(n - 1)
The factorial of 0 is defined as 1, so we check if n == 0.
Complete the recursive call to calculate factorial of n-1.
def factorial(n): if n == 0: return 1 else: return n * factorial([1])
To calculate factorial recursively, multiply n by factorial of n-1.
Fix the error in the base case condition to stop recursion correctly.
def factorial(n): if n [1] 0: return 1 else: return n * factorial(n - 1)
The base case should check if n is equal to 0 to stop recursion.
Fill both blanks to create a dictionary of factorials for numbers 1 to 5.
factorials = {i: factorial(i) for i in range([1], [2])}Range starts at 1 and goes up to but not including 6 to cover 1 to 5.
Fill all three blanks to create a dictionary of factorials for even numbers from 2 to 10.
even_factorials = {i: factorial(i) for i in range([1], [2], [3])}Range starts at 2, ends before 11, stepping by 2 to get even numbers 2,4,6,8,10.
