Observe The Following Python Codep Pre Langpython #720
Observe the following Python code?</p> <pre><code class="language-python"> def a(n): if n == 0: return 0 else: return n*a(n - 1) def b(n, tot): if n == 0: return tot else: return b(n-2, tot-2) </code></pre>
This multiple choice question (MCQ) is related to the book/course gs gs109 Python. It can also be found in gs gs109 Argument Passing, Variables and Recursion - Python Recursion - Quiz No.1.
Observe the following Python code?
def a(n): if n == 0: return 0 else: return n*a(n - 1) def b(n, tot): if n == 0: return tot else: return b(n-2, tot-2)
Both a() and b() aren’t tail recursive
Both a() and b() are tail recursive
b() is tail recursive but a() isn’t
a() is tail recursive but b() isn’t