Question: Ive got the code to print the 100th term. However, I need help getting to print a list of all the terms leading up to

Ive got the code to print the 100th term. However, I needIve got the code to print the 100th term. However, I need help getting to print a list of all the terms leading up to the 100th term. What do i have to do for it to print a list of the first 100 terms in the fibonaccir sequence?

Question 4: Fibonacci Sequence (3 points) The Fibonacci sequence has the form 1,1,2,3,5,8, Each successive number, after the first two, is found by adding the previous two numbers in the sequence. For example, the 7th number in the sequence is 5 +8 13. A possibly useful hint: We might not have explicitly talked about it in class yet, but one really useful thing that Python allows you to do is index lists using negative numbers, which allows you to move backwards through the list as you increase the size of the negative number, starting with -1. That means that if have the list stuff1,2,3,41, I can do stuff[-11 and I'l get the last number, 4. If I want the second to last number, I would do stuffl-2 Your goal is to write a function that computes 100 terms in the sequence. You function should accept a value (n) (the number of terms in the sequence you wish to compute) and return the list containing the first 100 terms of the Fibonacci sequence. Test your function for n = 4, 5, 6, 7 to ensure they match up with the sequence above. In [86]: # Write your solution to question 4 in this cell # Define your function here def FS (n): a,b 1,1 for i in range (n-1): a,b-b, atb return a Call your function here x = FS (100) print (x) 354224848179261915075

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!