Friday, January 22, 2021

python day 25 docstring and variable, scope

 # -*- coding: utf-8 -*-

"""

Created on Sat Jan 23 06:45:14 2021

topic: classes doc string and variables



@author: anil



class father():

    '''This is the father class developed by praveen

    inside addition method is there

    inside sub method is there

    inside mul method is there

    inside div method is there

    '''

    def __init__(self):

        print("this is father class default constructor")

        help(type(self))

  

    

    

father()

print(father.__doc__)

help(father)


b=10


class father():

    '''This is the father class developed by praveen

    inside addition method is there

    inside sub method is there

    inside mul method is there

    inside div method is there

    '''

    global b

    

    def __init__(self):

        a = 10

        

        

        self.name="praveen"

        print(self.name)

        print(a)

        print(b)

    def display():

        

        print(b)

        


#father()

father.display()

#print(a)

"""

b=30

c=10


class father():

    

    global b

    

    def __init__(self):

        a = 10

        self.name="praveen"

        #print(self.name)

        #print(a)

        #print(b)

        b =20

        print(b)

        b=50


    def display():

       

        print(b,c)


father()

print("this is display method inside values")

father.display()

print("a",a)

#print(a)




python day 24 class super function 2

 # -*- coding: utf-8 -*-

"""

Created on Fri Jan 22 21:48:01 2021

day 24:classes


@author: anil durgam



class engine():

    def piston():

        print("piston")


class carbody(engine):

    engine.piston()

    def seats():

        print("seats")

        

       

carbody()





class engine():

    def __init__(self,name,lastname):

        self.name=name

        self.lastname=lastname

        #print(self.name)

        

    def piston(self):

        print(self.name,self.lastname)


class carbody(engine):

    def __init__(self):

        pass

    

    def seats(self):

        print("seats")

        

    

         

#carbody()

s=engine("raju","kumar")

s.piston()



class engine():

    def __init__(self,name,lastname):

        self.name=name

        self.lastname=lastname

        #print(self.name)

        

    def piston(self):

        print(self.name,self.lastname)


class carbody(engine):

    def __init__(self,name,lastname):

        engine.__init__(self,name,lastname)

       

    #def seats(self):

        #print(self.name,self.lastname)

        

    def seatbelt():

        print("This is seatbelt method")

               

class backseat():

    def backseats(self):

        print("back seat method is working")

        

    

         

x=carbody("honda","spender")

x.piston()

"""



class engine():

    def __init__(self,name,lastname):

        self.name=name

        self.lastname=lastname

        #print(self.name)

        

    def piston(self):

        print(self.name,self.lastname)


class carbody(engine):

    def __init__(self,name,lastname):

        super().__init__(name,lastname)

       

    #def seats(self):

        #print(self.name,self.lastname)

        

    def seatbelt():

        print("This is seatbelt method")

               

class backseat():

    def backseats(self):

        print("back seat method is working")

        

    

         

x=carbody("honda","spender")

x.piston()

python class topic video