Computer Science
Write a Python program that creates a tuple storing first 9 terms of Fibonacci series.
Python
Python Tuples
49 Likes
Answer
lst = [0,1]
a = 0
b = 1
c = 0
for i in range(7):
c = a + b
a = b
b = c
lst.append(c)
tup = tuple(lst)
print("9 terms of Fibonacci series are:", tup)
Output
9 terms of Fibonacci series are: (0, 1, 1, 2, 3, 5, 8, 13, 21)
Answered By
18 Likes
Related Questions
What will the following code produce ?
Tup1 = (1,) * 3 Tup1[0] = 2 print(Tup1)
What will be the output of the following code snippet?
Tup1 = ((1, 2),) * 7 print(len(Tup1[3:8]))
Write a program that receives the index and returns the corresponding value.
Write a program that receives a Fibonacci term and returns a number telling which term it is. For instance, if you pass 3, it returns 5, telling it is 5th term; for 8, it returns 7.