You just have to implement one line of code in the bottom and rest is just infor
ID: 3593422 • Letter: Y
Question
You just have to implement one line of code in the bottom and rest is just information. ### First read the following function that caculates the Fib numbers def fib(k) if k in (0, 1): returnk return fib(k-1) fib(k-2) for i in range(20) print(i, fib(i)) ### The above function correctly calculates the Fib numbers as shown ### by the print statements above ### we are interested in how many function calls are made to calculate ### each Fib number ### we modify the above function to accomplish that ### Try to undertand the following code and see how the above goal ### is accomplished def fib1(k) if k == 0: return 0,1 if k == 1: return 1,1 u = fibl(k-1) v = fibl (k-2) return u[0] v[0], u[1]v[1]1 for i in range (20) print(i, fib1(i)) ### From the printout above, you should see that the number of function callsExplanation / Answer
#this is compiled in python 3 the one line of code you asked for
return u[2],u[1]+1,u[2]+u[0]
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.