Programming Examples
Python program that create a tuple storing first 9 terms of Fibonacci series
Write a Python program that create a tuple storing first 9 terms of Fibonacci series
Solution
fib=[]
a,b=-1,1
for i in range(1,10):
c=a+b
fib.append(c)
a,b=b,c
fib_tup=tuple(fib)
print(fib_tup)
Output/ Explanation:
(0, 1, 1, 2, 3, 5, 8, 13, 21)