Monday, 12 December 2016

Class to find out fibonacci series,table of number,pyramid


#define class
class ftp:

    #define function to find out fibonacci series
    def fib(self,n):
        self.a=0
        self.b=1
        print("fib series=",1,' ',end='')
        for i in range(1,n):
            self.s=self.a+self.b
            print(self.s,' ',end='')
            self.a=self.b
            self.b=self.s


    #define function to find out table of number
    def table(self,n):
        print("\n""table of",n)
        for i in range(1,11):
            print(n*i)

    #define function to display pyramid
    def py(self,n):
        print("Pyramid")
        for i in range(0,n+1):
            self.s=' '*(n-i)
            self.s=self.s+ '*'*(i*2-1)
            print (self.s)
ftp=ftp()  
n=int(input("enter number:"))
ftp.fib(n)
ftp.table(n)
ftp.py(n)


OUTPUT:

No comments:

Post a Comment