Question: Python Question A1c: Circle and Polygon (4 points) Create two new shapes: Circle and Polygon. Classes Circle and Polygon should inherit from Shape. Question A1c:
Python Question A1c: Circle and Polygon (4 points)
Create two new shapes: Circle and Polygon. Classes Circle and Polygon should inherit from Shape.


Question A1c: Circle and Polygon (4 points) Create two new shapes: Circle and Polygon . Classes Circle and Polygon should inherit from Shape For Circle at creation the radius has to be specified def init (self, x, y, r): . the-str-method should return a string in the same style as for Line and Rectangle . See the test case define the methods area and circumference. For this, you need to import pi from math For Polygon . an instance of Polygon is created by Polygon (1st) where 1st is a non-empty list of vertices represented by tuple, see the test case for an example The vertices are the 'corner of a polygon. We assume the polygon is non-self-intersecting . thestr method should return the string like in the test case . override the method move from Shape to move every vertex of the polygon define the method area. The area of a non-self-intersecting polygon with vertices is defined as where each Xiyi represents a vertex ("corner") of a polygon and where xn = x0 and yn = yo Note that the area of a convex polygon is positive if the points are in counterclockwise order and negative if they are in clockwise order. (The Wikipedia page takes the absolute value to avoid negative areas. Don't do this here # Create classes Circle and Polygon here class Circle(Shape): pass # Replace this line with your methods class Polygon (Shape): pass # Replace this line with your methods cCircle (1, 5, 1) p Polygon([ (0, 0), (4, 0), (2, 2), (4, 4), (e, 4), (2, 2)])
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
