Hexagon

Report a typo

The class Hexagon represents the regular hexagons (all sides are equal in length and all angles equal 120120 ^ \circ). The only parameter needed to create a regular hexagon is the length of its side tt .

Create a method get_areathat calculates the area of the hexagon according to the formula:

S=33t22S = \frac{3\sqrt{3} * t^2}{2}.

The name of the method has to be get_area! The method doesn't receive any parameters and it doesn't print anything, it just returns the calculated area (rounded to 3 decimals). You do NOT need to call the method in your program!

To calculate the square root use the math.sqrt(x) method (the math module has already been imported).

There is no input to read, so you do NOT need to work with it, and nothing else is required.

Sample Input 1:

1

Sample Output 1:

2.598

Sample Input 2:

5.4

Sample Output 2:

75.760
Write a program in Python 3
import math


class Hexagon:
def __init__(self, side_length):
self.side_length = side_length


# create get_area here
___

Create a free account to access the full topic