Python Program To Find The Fibonacci Series

Hello everyone, welcome to In this article we will going to discuss about Python program to find squares of the summation of n numbers.

Here is an example of a Python program that prints the Fibonacci series of a given number:

Code For Python Program To Find The Fibonacci Series

def fibonacci_series(n):
    fib = [0, 1]
    for i in range(2, n):
        fib.append(fib[i-1] + fib[i-2])
    return fib

n = int(input("Enter the number of elements: "))
print("Fibonacci series of", n, "elements is", fibonacci_series(n))


Enter the number of elements: 4
Fibonacci series of 4 elements is [0, 1, 1, 2]


In this program, the fibonacci_series(n) function takes one argument: a number n. The function uses a for loop to generate the Fibonacci series of n numbers, which is stored in a list called fib.

The function uses two initial values 0 and 1 to generate the fibonacci series. And in each iteration, it sums the previous two numbers in the list and append it to the list. Finally, the function returns the list of Fibonacci series of n numbers.

The program starts by asking the user to enter the number of elements. This value is stored in the variable n. The function fibonacci_series is called with n as an argument. The returned value of the function is printed with message “Fibonacci series of n elements is “.

As before, it’s always a good practice to validate the input, in this case, make sure the entered number of elements is not negative or zero.

Python program to find squares of the summation of n numbers


If you liked this post, then please share this with your friends and make sure to bookmark this website for more awesome content.

If You Like This Page Then Make Sure To Follow Us on Facebook, G News and Subscribe Our YouTube Channel. We will provide you updates daily.
facebook sharing button Share
twitter sharing button Tweet
whatsapp sharing button Share
telegram sharing button Share
pinterest sharing button Pin

Leave a Comment