Oh Snap!

Please turnoff your ad blocking mode for viewing your site content

Hit enter after type your search item

Python 3 Script to Print the Fibonacci Series Sequence Using For and While Loop Full Tutorial For Beginners

/
/
/
45 Views

 

Welcome folks today in this blog post we will be building a fibonacci series sequence in python using for and while loop. All the full source code of the application is shown below.

 

 

Get Started

 

 

In order to get started we need to make an app.py file and copy paste the following code

 

First of all we will be using the while loop to print the series

READ  Python FFMPEG-Python Library Example to Flip Video in Horizontal and Vertical Direction Full Project For Beginners

 

app.py

 

# Python Fibonacci series Program using While Loop

# Fibonacci series will start at 0 and travel upto below number
Number = int(input("\nPlease Enter the Range Number: "))

# Initializing First and Second Values of a Series
i = 0
First_Value = 0
Second_Value = 1
           
# Find & Displaying Fibonacci series
while(i < Number):
           if(i <= 1):
                      Next = i
           else:
                      Next = First_Value + Second_Value
                      First_Value = Second_Value
                      Second_Value = Next
           print(Next)
           i = i + 1

 

 

Now we can print the series by the for loop

READ  Python 3 Numpy Library Example to Generate Random Number Arrays (One + Two + Three Dimensional) Full Project For Beginners

 

app.py

 

# Python Fibonacci series Program using For Loop

# Fibonacci series will start at 0 and travel upto below number
Number = int(input("\nPlease Enter the Range Number: "))

# Initializing First and Second Values of a Series
First_Value = 0
Second_Value = 1
           
# Find & Displaying Fibonacci series
for Num in range(0, Number):
           if(Num <= 1):
                      Next = Num
           else:
                      Next = First_Value + Second_Value
                      First_Value = Second_Value
                      Second_Value = Next
           print(Next)

 

 

Now if you execute the python script by typing the below command

READ  Python Tkinter GUI Script to Make a Basic Calculator in Sweet UI Full Project For Beginners

 

python app.py

 

 

 

Leave a Comment

Your email address will not be published. Required fields are marked *

This div height required for enabling the sticky sidebar
Coding Shiksha 2020. All Rights Reserved.
Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views :