Inheritance(OOP)

##by ineheritance we can make available the object of other 
#in object of other class :-inheritance(think)
class animal:
def __init__(self,colour):
self.colour=colour
def introduce(self):
print("i am an animal")
def makesound(self):
print("making sound")
class dog(animal):
def takecare(self):
print("i am taking care of you")
wild_animal=animal("brown")
puppy=dog("white")
wild_animal.makesound()

puppy.introduce()  

##obejct is use to call a method, here puppy is object and introduce is method



"C:\Users\darul Haram\PycharmProjects\pythonProject2\venv\Scripts\python.exe" "C:/Users/darul Haram/PycharmProjects/pythonProject2/venv/Lib/inheritance(OOP).py"

making sound

i am an animal


Process finished with exit code 0

 

Comments

Popular posts from this blog

XAMPP, SQL BASIC COMMANDS

The Minion Game Hackerrank Solution

Arrays - DS | HackerRank Solutions