226 views

1 Answer

1 1 vote

The function is called as:

r1 = virfib_sq(1)

First, the function prints $\texttt{n}$.

print(n)

Since $\texttt{n = 1}$, Python prints:

1

Then the base case is true:

if n <= 1:
    return n

So the function returns $\texttt{1}$ and stores it in $\texttt{r1}$. But $\texttt{r1}$ is not printed.

Final output:

1
Answer:
Position:
Show:

Related questions

2 2 votes
1 1 answer
253
253 views
GO Classes asked Jul 1
253 views
Consider the following Python code:def virfib_sq(n): print(n) if n <= 1: return n return (virfib_sq(n - 1) + virfib_sq(n - 2)) 2 r0 = virfib_sq(0)What would be the outp...
6 6 votes
1 1 answer
444
444 views
GO Classes asked Jul 1
444 views
Consider the following Python code:def virfib_sq(n): print(n) if n <= 1: return n return (virfib_sq(n - 1) + virfib_sq(n - 2)) 2 r4 = virfib_sq(4)What would be the outp...
4 4 votes
1 1 answer
269
269 views
GO Classes asked Jul 1
269 views
Consider the following Python code:def virfib_sq(n): print(n) if n <= 1: return n return (virfib_sq(n - 1) + virfib_sq(n - 2)) 2 r3 = virfib_sq(3)What would Python disp...
3 3 votes
1 1 answer
227
227 views
GO Classes asked Jul 1
227 views
Consider the following Python code:def virfib_sq(n): print(n) if n <= 1: return n return (virfib_sq(n - 1) + virfib_sq(n - 2)) 2 r2 = virfib_sq(2)What would be the outp...