Assignment Helper | Python Program to Print the Fibonacci sequence

assignment advertisement

WhatsApp Now(+91-9760648231) for assignments, projects, and homework help in programming.

Question

Write a Python Program to Print the Fibonacci sequence.

Answer

nterms = int(input("How many terms? "))

n1, n2 = 0, 1
count = 0

if nterms <= 0:
   print("Please enter a positive integer")
elif nterms == 1:
   print("Fibonacci sequence upto",nterms,":")
   print(n1)
else:
   print("Fibonacci sequence:")
   while count < nterms:
       print(n1)
       nth = n1 + n2
       n1 = n2
       n2 = nth
       count += 1

Also Read:

Browse post tags:

write a python program to print fibonacci series
fibonacci code in python
python code for fibonacci series
python program to print fibonacci series
fibonacci program in python
fibonacci python
fibonacci sequence python
fibonacci series program in python
fibonacci series python
fibonacci series in python using for loop
python fibonacci series
print fibonacci series in python
write a program to print fibonacci series in python
fibonacci series in python

Share:
Avatar of Harry

Author: Harry

Hello friends, thanks for visiting my website. I am a Python programmer. I, with some other members, write blogs on this website based on Python and Programming. We are still in the growing phase that's why the website design is not so good and there are many other things that need to be corrected in this website but I hope all these things will happen someday. But, till then we will not stop ourselves from uploading more amazing articles. If you want to join us or have any queries, you can mail me at [email protected] Thank you