{"id":23688,"date":"2021-10-03T20:26:55","date_gmt":"2021-10-03T14:56:55","guid":{"rendered":"https:\/\/python-programs.com\/?p=23688"},"modified":"2021-11-22T18:33:26","modified_gmt":"2021-11-22T13:03:26","slug":"python-program-for-volume-of-pyramid","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-for-volume-of-pyramid\/","title":{"rendered":"Python Program for Volume of Pyramid"},"content":{"rendered":"

Given the base, height, area of a pyramid and the task is to calculate the volume of given pyramid types in python.<\/p>\n

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

A pyramid is a three-dimensional geometric shape created by connecting all of the corners of a polygon to a central apex.<\/p>\n

Pyramids come in a variety of shapes and sizes. They are usually named after the type of base they have. Let’s take a look at some of the most common types of pyramids below.<\/p>\n

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

The Volume of square base pyramid\u00a0 = (1\/3) * (b^2) * h
\nThe volume of triangular base pyramid = (1\/6) * a * b * h
\nThe Volume of pentagonal base pyramid = (5\/6) * a * b * h
\nThe volume of a hexagonal base pyramid = a * b * h<\/p>\n

where b= base of the pyramid<\/p>\n

h= height<\/p>\n

a= area<\/p><\/blockquote>\n

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

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

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

Given base = 3\r\nGiven height = 5\r\nGiven area = 20<\/pre>\n

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

The Volume of triangular base pyramid with given base, height, area { 3 , 5 , 20 } =  49.97999999999999\r\nThe Volume of square base pyramid with given base, height, area { 3 , 5 , 20 } =  14.849999999999998\r\nThe Volume of pentagonal base pyramid with given base, height, area { 3 , 5 , 20 } =  249.0\r\nThe Volume of hexagonal base pyramid with given base, height, area { 3 , 5 , 20 } =  300<\/pre>\n

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

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

Given base = 4\r\nGiven height = 6.2\r\nGiven area =  15<\/pre>\n

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

The Volume of triangular base pyramid with given base, height, area { 4.0 , 6.2 , 15.0 } = 61.9752\r\nThe Volume of square base pyramid with given base, height, area { 4.0 , 6.2 , 15.0 } = 32.736000000000004\r\nThe Volume of pentagonal base pyramid with given base, height, area { 4.0 , 6.2 , 15.0 } = 308.76\r\nThe Volume of hexagonal base pyramid with given base, height, area { 4.0 , 6.2 , 15.0 } = 372.0<\/pre>\n

Program for Volume of Pyramid in Python<\/h2>\n

Below are the ways to calculate the volume of given pyramid types in python:<\/p>\n