Question: Using Python. Create a shape Class with one data member called side1 and two class methods called getArea and getPerimeter. They are empty methods or

Using Python.

Create a shape Class with one data member called side1 and two class methods called getArea and getPerimeter. They are empty methods or abstract methods. You can write empty methods as

def getArea(self):

pass

Or

def getArea(self):

Or

def getArea(self):

return

Or

def getArea(self):

return 0

Create a Class called Square as a subclass of Shape and implement the data member and methods side1, getArea and getPerimeter.

Create another Class called Rectangle as a subclass of Shape and implement Shape.side1 and Rectangle classs side2. Write the methods getArea and getPerimeter for Rectangle class.

Create another class called Triangle as a subclass of Shape and implement Shape.side1 and Triangles classs side2 and side3. Write the methods getArea and getPerimeter for Triangle class.

Please keep the scope of this assignment as simple as possible and learn the inheritance. That is the objective. Once we get all the concepts, we can expand by adding more functionalities.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!