Python Program to Print Fibonacci Series

« Previous Program Next Program »

Print Fibonacci Series in Python

To print fibonacci series in python, you have to ask from user to enter the limit or to enter the total number of term to print the fibonacci series upto the given term.

As we know that the Fibonacci series starts from 0 and 1, and after that, every next number is the summation of the last two number. Therefore to print fibonacci series in python, just print 0 and 1 if the given limit is greater than 2 and then apply the summation of the previous two numbers to print the next number as shown in the program given below.

Python Programming Code to Print Fibonacci Series

Following python program ask from user to enter the limit upto which he/she want to print the Fibonacci series to print Fibonacci series upto to the given term:

# Python Program - Print Fibonacci Series
while True:
	print("Enter 'x' for exit.")
	terms = input("Upto how many terms ? ")
	if terms == 'x':
		term = int(terms)
		a = 0
		b = 1
		count = 2
		if term <=0:
			print("Enter a positive number...")
		elif term == 1:
			print(a, ",",b,end=",")
			while count < term:
				c = a + b
				a = b
				b = c
				count = count + 1

Here is the sample run of the above python program to illustrates how to print Fibonacci series:

python print fibonacci series

Same Program in Other Languages

You may also like to learn or practice the same program in other popular programming languages:

« Previous Program Next Program »

Latest 5 Posts by CodesCracker


Quick Links
Signup - Login - Give Online Test