Generation

generate functionSat, 11 Feb 2023

a. It should have a function ‘description()’ which prints the name and age of the dog. 🔴 b. It should have a function ‘get_info()’ which prints the coat color of the dog. 🔴 c. Create child classes ‘JackRussellTerrier’ and ‘Bulldog’ which is inherited from the class ‘Dog’. It should have at least two methods of its own. 🔴 d. Create objects and implement the above functionalities

class Dog: def __init__(self, name, age, color): self.name = name self.age = age self.color = color def description(self): print("My name is {}. I am {} years old. I am {}".format(self.name, self.age, self.color)) def get_info(self): print("I am from the family of dog. My color is {}".format(self.color)) class JackRussellTerrier(Dog): def get_info(self): print("I am a Jack Russell Terrier. My color is {}".format(self.color)) class Bulldog(Dog): def get_info(self): print("I am a Bulldog. My color is {}".format(self.color)) Mango = Dog("Mango", 22, "Yellow & Brown") Mango.description() Mango.get_info() Jack = JackRussellTerrier("Jack", 7, "White") Jack.description()

Questions about programming?Chat with your personal AI assistant