You are required to demonstrate the concept of Object-Oriented Programming (OOP) in Python by creating a simple class that models real-world objects.
Design a class named Dog that represents different dogs with shared and individual characteristics.
Each dog has a common species and unique attributes such as name and breed. The class should also define behavior that allows a dog to bark.
Create a class Dog with the following:
A class attribute:
species = "Canine" (common for all dogs)Instance attributes (defined using constructor):
namebreedImplement a constructor __init__() that initializes:
Define a method:
bark() → This method should print a message in the format:
<name> says Woof!
Create at least two objects of the Dog class:
Call the bark() method for at least one object and observe the output.
Buddy says Woof!
Write the Python code to define a class named Student with a constructor that initializes three attributes: name, age, and grade. Add a method named info() that prints the student’s details. Create two objects:
• student1 with name “Hamza”, age 8, grade 3
• student2 with name “Muhammad”, age 15, grade 10
Print the name of the first student and call the info() method for both objects.