DEV Community

Durga Pokharel
Durga Pokharel

Posted on

Day 10 of 100DaysOfCode: Object Inheritance

Today is my 10th day of #100daysofcode. I learned more properties of CSS like applied visual Design challenges, Create visual balance using the text-align property, adjusting the width of an element using the width property, adjusting the height of an element using the height property, making use of (strong, U, em , S, hr..) tag from Freecodecamp. I also learned about database on pythoncoursera

I also tried to write code in class on python.

Object Inheritance

Here we have two template. Child template is related to the parent template. Here we add capabilities or extend the capabilities of parent. In the code FootballFan is class which extend the PartyAnimal.It has all the property of PartyAnimal. There are two variables x and name these are attributes also. And we have a constructor that has the name parameter.

After that we have a new calss FootballFan inside the parenthesis we have a name of different class. FootballFan is everything PartyAnimal is plus point we define here. So FootballFan has x instance variable, point inastance variable and name instance variable. And we give object to the PartyAnimal and FootballFan.

class PartyAnimal():
    x = 0
    name = ''
    def __init__(self,z): = z
    def party(self):
        self.x = self.x + 1
        print(,'party count',self.x)

class FootballFan(PartyAnimal):
    points = 0
    def touchdown(self):
        self.points = self.points + 7

s = PartyAnimal('sally')

j = FootballFan('jim')

Enter fullscreen mode Exit fullscreen mode

Day 10 of #100daysofcode and #Python
* More about database on python
* More about CSS properties like applied visual challenges, create a visual balance using the text align property, adjusting the (width, height) of an element using the width property
* Object inheritance

— Durga Pokharel (@mathdurga) January 3, 2021

Discussion (1)

otumianempire profile image
Otu Michael

You will get there.