ProgrammingHardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
def f(n):
    if n <= 1:
        return n
    return f(n - 1) + f(n - 2)
print(f(20), f.__defaults__)
  1. A. 4181 None
  2. B. 6765 0
  3. C. 6765 None
  4. D. 6765 ()

Correct answer: C. 6765 None

f(20) is the 20th Fibonacci number with f(0)=0 and f(1)=1, which is 6765. The function has no default arguments, so __defaults__ is None.

More Python Programming questions

Exams that ask this topic