Fibonacci Series in Python || Basic Program || Classes || Python
In this we are going to see a basic program to print fibonacci series using classes in Python Programming Language.



class Fibonacci:
    def __init__(self):
        self.a = 0
        self.b = 0
        self.c = 0
 
    def generate(self, n):
        self.a = 0
        self.b = 1
        print(self.a, end='')
        print(" ", end='')
        print(self.b, end='')
 
        i = 1
        while i <= n - 2:
            self.c = self.a + self.b
            print(" ", end='')
            print(self.c, end='')
            self.a = self.b
            self.b = self.c
            i += 1
 
 
n = int(input("Enter the length of Fibonacci Series:"))
print("Fibonacci Series:- ")
fib = Fibonacci()
fib.generate(n)
 
#Coded by SAAHIL


#ENJOY CODING


Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post