# Python Program to calculate area of Enneagon

In this tutorial, we shall write a Python program to find the area of an Enneagon. An Enneagon (also called as nonagon) is a 9-sided polygon. If all the sides of a polygon are equal, it is called a regular polygon. To calculate the area of Enneagon, we can use either of the following measurement.

- Length of the side (s)
- Circumradius (r)
- Apothem (a)

Since the polygon is regular, all the internal angles are equal to (n-2)180^{o}/n. Here n is the number of sides and is equal to 9. Therefore, all the internal angles are equal to 140^{o}.

## Area of Enneagon using the length of side s

Above Triangle is one of the 9 triangles cast by the vertices onto the center of the enneagon. The aim is to find the area of the triangle in terms of the length of side s. The 360^{o} at the center of the enneagon is divided by the triangles equally. Therefore, the angle is 360/9 = 40^{o}. We draw a perpendicular bisector to the side and the length of the bisector is h.

=> Angle t = 40/2 = 20^{o }

tan(t) = (s/2)/h

=>h = s/2tan(t)

Area of the triangle = (1/2) * (s) * (h)

= (s^{2})/4tan20^{o}

Area of the Enneagon = 9 * Area of Triangle = 6.1818 * (s^{2})

## Area of Enneagon using Circumradius r

h = rcos(t)

x = rsin(t)

Area of the triangle = (1/2) * (2x) * (h) = (r^{2}) * sin(t) * cos(t)

= (r^{2} / 2) * sin(2t)

Area of the Enneagon = (9/2) * sin40 * (r^{2}) = 2.8925 * (r^{2})

## Area of Enneagon using Apothem a

The line from the center to the mid of the side is called apothem.

x = atan(t)

Area of the triangle = (1/2) * (2x) * (a)

= (a^{2}) * tan(t)

Area of the Enneagon = (9 * tan20) * (a^{2}) = 3.2757 * (a^{2})

## Program

Below is our Python program to calculate and find the area of Enneagon that contains the measurements methods that I have mentioned above:

print("Enter 1 to calculate area by using side s") print("Enter 2 to calculate area by using circumradius r") print("Enter 3 to calculate area by using apothem a") ch = int(input("")) def side(): s = int(input("Enter length of side s: ")) print("Area is equal to {}".format(6.1818 * (s ** 2))) def cirrad(): r = int(input("Enter length of circumradius r: ")) print("Area is equal to {}".format(2.8925 * (r ** 2))) def apothem(): a = int(input("Enter length of apothem a: ")) print("Area is equal to {}".format(3.2757 * (a ** 2))) options = { 1 : side, 2: cirrad, 3: apothem,} if(ch==1 or ch==2 or ch==3): options[ch]() else: print("Wrong choice. Please try again")

Output:

Enter 1 to calculate area by using side s Enter 2 to calculate area by using circumradius r Enter 3 to calculate area by using apothem a 3 Enter length of apothem a: 2 Area is equal to 13.1028

Thank You for Reading and Keep Learning ðŸ™‚

- Also Read: Find the Area of Polygon in Python

## Leave a Reply