Question: How to create a class? Create a file hw2.py and define three classes, Polygon, Rectangle and Triangle (see next page for a visual representation). 1.

How to create a class? Create a file hw2.py and define three classes, Polygon, Rectangle and Triangle (see next page for a visual representation). 1. Polygon will be the super class of Triangle and Rectangle. 2. Create a class, Polygon. Its _init_() method should take nbr_sides (number of sides) as argument. Make sure to set that instant variable appropriately in the body of the __init_()method. 3. The Polygon should have methods whoamI and howmanysides. For now, just add pass in the body of these two methods. 4. Complete the implementation of the Rectangle class which takes two arguments breadth and length to create a Rectangle object. The Rectangle class is a subclass of Polygon class. 5. Complete the implementation of the Triangle class which takes three arguments (a, b, and c) to create a Triangle object. The Triangle class is a subclass of Polygon class. 6. Add area and perimeter methods to the Rectangle class and Triangle class, and as before, for now just add pass in the body of these two methods. The pass statement is used as a placeholder for future code. When the pass statement is executed, nothing happens, but you avoid getting an error when empty code is not allowed
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
