{"id":18865,"date":"2021-08-26T10:37:39","date_gmt":"2021-08-26T05:07:39","guid":{"rendered":"https:\/\/python-programs.com\/?p=18865"},"modified":"2021-11-22T18:37:19","modified_gmt":"2021-11-22T13:07:19","slug":"python-program-to-compute-the-area-and-perimeter-of-octagon","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-compute-the-area-and-perimeter-of-octagon\/","title":{"rendered":"Python Program to Compute the Area and Perimeter of Octagon"},"content":{"rendered":"

In the previous article, we have discussed Python Program to Compute the Area and Perimeter of Heptagon<\/a>
\nMath Module :<\/strong><\/p>\n

Python’s math module is a built-in module. By importing this module, we can perform mathematical computations.<\/p>\n

Numerous mathematical operations like ceil( ),floor( ),factorial( ),mod( ),value of pi ,…..etc .can be computed with the help of math module.<\/p>\n

Octagon:<\/strong><\/p>\n

An octagon is a polygon with eight sides. It has eight different angles.<\/p>\n

Octagon = octa + gon, where octa is the number eight and gon is the number of sides.<\/p>\n

In an octagon, there are 20 diagonals.<\/p>\n

Formula to calculate the area of an Octagon:<\/b><\/p>\n

\n
\n
\n
A = 2(1+\u23b72)a\u00b2<\/i><\/b><\/div>\n
<\/div>\n
In which\u00a0 a is the Octagon’s <\/b>side length<\/div>\n<\/div>\n<\/div>\n<\/div>\n
<\/div>\n
Formula to calculate the perimeter of a Octagon<\/b>:<\/b><\/strong><\/div>\n
<\/div>\n
perimeter = 8a<\/div>\n
<\/div>\n
Given the Octagon’s side length and the task is to calculate the area and perimeter of the given Octagon<\/b><\/strong>.<\/div>\n
<\/div>\n
Examples:<\/strong><\/div>\n
\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given The Octagon's side length = 6<\/pre>\n

Output:<\/strong><\/p>\n

The Octagon's Area with given side length { 6 } = 173.82337649086284\r\nThe Octagon's Perimeter with the given side length { 6 } = 48<\/pre>\n

Example2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given The Octagon's side length = 12.5<\/pre>\n

Output:<\/strong><\/p>\n

The Octagon's Area with given side length { 12.5 } = 754.4417382415921\r\nThe Octagon's Perimeter with the given side length { 12.5 } = 100.0<\/pre>\n<\/div>\n

Program to Compute the Area and Perimeter of Octagon<\/h2>\n

Below are the ways to Calculate the area and perimeter of a heptagon with the given Octagon’s side length:<\/p>\n