Write a Program to Print Fibonacci Series in Python

Write a Program (WAP) to Print Fibonacci Series in Python using for loop with source code. Further, addition of terms of Fibonacci series. This is a good program for beginners, CBSE KV Class 11 and 12 students practical project file and programmers.

What is Fibonacci Series?

In Fibonacci series numbers go from 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ……

The 3rd term is sum of 1 and 2 and 4th term is sum of 2nd and 3rd term and so on…. In general we can say that the nth term is the sum of (n-1)th and (n-2)th term. Here in starting 0,1 is given as default then this series starts growing as per the definition given.

Write a program WAP to print Fibonacci series up to n terms, also find sum of series.

fibonacci series

How our program work – an explanation

n=int(input(“Enter the number of terms in Fibonacci series”)) # n is integer input and asking up to how many terms are
#to be printed
a,b=0,1 #Here a is initialized 0 and b is initialized 1.
s=a+b #sum of first and second term i.e 0,1 then after then in loop other additions
print(a,b,end=” “) #intital 2 means 0 and 1 is printed a=0 b=1
for i in range(n-2): #it is for loop where i (new variable) goes into looping from 1 time to n-2 time . 2 times are printed #from the above line
print(a+b,end=” “) # Now a+b is printed
a,b=b,a+b #now the values will be changed as written this will go on till loop
s=s+b #sum of digits
print(“Sum of”,n,”terms of series =”,s)

Output fibonacci series in python-

fibonacci series

The shell window ( above window) asks for input which is how much you want to output.
In the first input we have given 5. Which means it will show 5 value . Now the first 2 digits are 0,1

then the loop starts and runs 3 time to give 1,2,3 . Similarly other inputs are there showing their output in their command.Series and the addition of the numbers is also given in last line .

Next the input is 10 and then 20. check them out they are given above pic.

Source code for the “Write a Program to Print Fibonacci Series in Python “- Click here

For more python programs- Click here

Hello World Program in Python

Input a welcome message and display it in Python

Display the larger / smaller number in Python.

Greatest of Three Numbers in Python using Nested if

Patterns using nested loop in Python

Program to Print Pattern in Python

Program to input the value of x and n and sum of series in Python

Python Program for Armstrong, Prefect Number, Palindrome

Program of Prime number by recursion in python

Prime Number Program in Python

Write a Program to Print Fibonacci Series in Python

LCM and GCD program in Python

Python program to count number of vowels in a string

Whether a String is Palindrome or not in Python

Bubble Sort Program in Python

Linear search in python using list

Program to read a text file in python

Python program to read a file line by line

Program to Count Vowels and Consonants in Python

Stack Program in Python

Queue Program in Python

Python Leap Year Program for Beginners

Python Program to Print Series and Addition

Binary Search Program in Python

Program to find sum of digits in python

Sum of numbers divisible by 3 and 5 in python