Question
A polygon is a shape with multiple sides. Polygon can be of different types: Triangle is the three- sided polygon. Rectangle is a
A polygon is a shape with multiple sides. Polygon can be of different types: • Triangle is the three- sided polygon. • Rectangle is a four-sided figure. • Pentagon has five-sides • Hexagon has six- sides. Create in Python the parent class (superclass) and subclasses to represent the given problem.
To practice function overloading, overload the calculateArea() function for each of the sub class and calculate area based on the following formulas. You will need to import math to use the square root function math.sqrt().
o Area of a Triangle = (base *height)/0.5
o Area of a Rectangle =(base*height)
o Area of a Pentagon= ((base *height)/0.5) 10
o Area of a Hexagon= ((6 * base * height) + (3 * math.sqrt(3) * base * base))
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started