Question: Fibonacci the Fibonacci sequence starts 1, 1, 2, 3, 5, 8 Each number in the sequence (after the first two) is the sum of the

Fibonacci the Fibonacci sequence starts 1, 1, 2, 3, 5, 8 Each number in the sequence (after the first two) is the sum of the previous two. Write a program called Fibonacci.py or Lab6a.py that computes and outputs the nth Fibonacci number, where n is a value entered by the user.

o Hint: use 3 variables, one to store the sum of the previous two numbers, one to print out each iteration of the loop (this number is initialized to 1, and another to save the number you print to the screen (this number is initialized to 0)

o How would you get the program not to print out the last comma (,)?

What we have:

print("This program computes a Fibonacci series") n = int(input("Please enter what term in the Fibonacci sequence you would like to know:")) x1 = 0 x2 = 1 x3 = 0 print(n, end=",")[1, 1, 2, 3, 5, 8, 13, 21, 34, 55,] for i in range(n): print(x2) x1 = x1 + x2 x1 = x2 x2 = x3

What code should return:

This program computes a Fibonacci series

Please enter what term in the Fibonacci sequence you would like to know:

1, 1, 2, 3, 5, 8, 13, 21, 34, 55

Process finished with exit code 0

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!