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