{"id":23715,"date":"2021-10-03T20:27:01","date_gmt":"2021-10-03T14:57:01","guid":{"rendered":"https:\/\/python-programs.com\/?p=23715"},"modified":"2021-11-22T18:33:26","modified_gmt":"2021-11-22T13:03:26","slug":"python-program-for-volume-and-surface-area-of-octahedron","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-for-volume-and-surface-area-of-octahedron\/","title":{"rendered":"Python Program for Volume and Surface Area of Octahedron"},"content":{"rendered":"
Given the side of an octahedron and the task is to calculate the volume and surface area of an octahedron for the given side in python.<\/p>\n
Octahedron :<\/strong><\/p>\n A regular octahedron has eight faces, all of which are equilateral triangles. An octahedron’s area is equal to 2 multiplied by the length of an edge squared multiplied by the square root of three.<\/p>\n Formulas:<\/strong><\/p>\n Surface Area of an Octahedron = 2*(sqrt(3))*(side*side)<\/p>\n The volume of an Octahedron = \u221a2\/3 \u00d7 side3<\/sup><\/p><\/blockquote>\n Examples:<\/strong><\/p>\n Example1:<\/strong><\/p>\n Input:<\/strong><\/p>\n Output:<\/strong><\/p>\n Example2:<\/strong><\/p>\n Input:<\/strong><\/p>\n Output:<\/strong><\/p>\n Below are the ways to calculate the volume and surface area of an octahedron for the given side in python:<\/p>\n Approach:<\/strong><\/p>\n Below is the implementation:<\/strong><\/p>\n Output:<\/strong><\/p>\n Approach:<\/strong><\/p>\n Below is the implementation:<\/strong><\/p>\n Output:<\/strong><\/p>\n <\/p>\n <\/p>\n","protected":false},"excerpt":{"rendered":" Given the side of an octahedron and the task is to calculate the volume and surface area of an octahedron for the given side in python. Octahedron : A regular octahedron has eight faces, all of which are equilateral triangles. An octahedron’s area is equal to 2 multiplied by the length of an edge squared …<\/p>\nGiven side = 5<\/pre>\n
The Surface Area of an octahedron for the given side { 5 } = 86.60254037844386\r\nThe volume of an Octahedron for the given side { 5 } = 58.92556509887897<\/pre>\n
Given side = 10<\/pre>\n
The Surface Area of an octahedron for the given side { 10 } = 346.41016151377545\r\nThe volume of an Octahedron for the given side { 10 } = 471.40452079103176<\/pre>\n
Program for Volume and Surface Area of Octahedron in Python<\/h2>\n
\n
Method #1: Using Mathematical Formula (Static Input)<\/h3>\n
\n
# Import math module using the import keyword.\r\nimport math\r\n# Give the side as static input and store it in a variable.\r\ngvn_side = 5\r\n# Calculate the surface area of an octahedron using the above given mathematical\r\n# formula and math.sqrt() function.\r\n# Store it in another variable.\r\nsurfce_area = (2*(math.sqrt(3))*(gvn_side*gvn_side))\r\n# Calculate the volume of an octahedron using the above given mathematical formula\r\n# and math.sqrt() function.\r\n# Store it in another variable.\r\nrslt_volum = ((gvn_side*gvn_side*gvn_side)*(math.sqrt(2)\/3))\r\n# Print the surface area of a given octahedron.\r\nprint(\r\n \"The Surface Area of an octahedron for the given side {\", gvn_side, \"} = \", surfce_area)\r\n# Print the volume of a given octahedron.\r\nprint(\r\n \"The volume of an Octahedron for the given side {\", gvn_side, \"} = \", rslt_volum)\r\n<\/pre>\n
#include <iostream>\r\n#include<math.h>\r\n\r\nusing namespace std;\r\n\r\nint main() {\r\n double gvn_side = 5;\r\n double surfce_area = ( 2 * ( sqrt ( 3 ) ) * ( gvn_side * gvn_side ) );\r\n double rslt_volum = ( ( gvn_side * gvn_side * gvn_side ) * ( sqrt ( 2 ) \/ 3 ) );\r\n cout << \"The Surface Area of an octahedron for the given side {\" << gvn_side << \"} = \" << surfce_area << endl;\r\n cout << \"The volume of an Octahedron for the given side {\" << gvn_side << \"} = \" << rslt_volum << endl;\r\n\r\n}<\/pre>\n
The Surface Area of an octahedron for the given side { 5 } = 86.60254037844386\r\nThe volume of an Octahedron for the given side { 5 } = 58.92556509887897<\/pre>\n
Method #2: Using Mathematical Formula (User Input)<\/h3>\n
\n
# Import math module using the import keyword.\r\nimport math\r\n# Give the side as user input using the int(input()) function and store it in a variable.\r\ngvn_side = int(input(\"Enter some random number = \"))\r\n# Calculate the surface area of an octahedron using the above given mathematical\r\n# formula and math.sqrt() function.\r\n# Store it in another variable.\r\nsurfce_area = (2*(math.sqrt(3))*(gvn_side*gvn_side))\r\n# Calculate the volume of an octahedron using the above given mathematical formula\r\n# and math.sqrt() function.\r\n# Store it in another variable.\r\nrslt_volum = ((gvn_side*gvn_side*gvn_side)*(math.sqrt(2)\/3))\r\n# Print the surface area of a given octahedron.\r\nprint(\r\n \"The Surface Area of an octahedron for the given side {\", gvn_side, \"} = \", surfce_area)\r\n# Print the volume of a given octahedron.\r\nprint(\r\n \"The volume of an Octahedron for the given side {\", gvn_side, \"} = \", rslt_volum)\r\n<\/pre>\n
Enter some random number = 10\r\nThe Surface Area of an octahedron for the given side { 10 } = 346.41016151377545\r\nThe volume of an Octahedron for the given side { 10 } = 471.40452079103176<\/pre>\n