Monday 10 April 2023

Write a python program to demonstrate inheritance

 class Animal:

    name = ''

    type = 'carnivorous'

    def base_details(self):

        print(F'{} & {self.type}')

class Dog(Animal):

    def features(self): = "Puppy, Gradion, Tommy & jacob etc"

        features = "The dog is a mammal with sharp teeth, an excellent sense of smell, and a fine sense of hearing."

        print(f'Best friend of Human. Lovely names are {}\nIt is {self.type}.\n{features}')

class Cat(Animal):

    def print_type(self): = "Cat or Pussy"

        self.type = "herbivorous"

        print(f'{} is a {self.type}.')

dog = Dog()


cat = Cat()