{"id":23680,"date":"2021-10-03T20:26:50","date_gmt":"2021-10-03T14:56:50","guid":{"rendered":"https:\/\/python-programs.com\/?p=23680"},"modified":"2021-11-22T18:33:26","modified_gmt":"2021-11-22T13:03:26","slug":"python-program-for-volume-and-surface-area-of-frustum-of-cone","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-for-volume-and-surface-area-of-frustum-of-cone\/","title":{"rendered":"Python Program for Volume and Surface Area of Frustum of Cone"},"content":{"rendered":"
Given the height, slant height, smaller and bigger radius of a frustum cone, the task is to find the volume and surface area of the frustum of a given cone in python.<\/p>\n
Frustum of a Cone :<\/strong><\/p>\n A frustum in geometry is the portion of a solid (typically a cone or pyramid) that lies between one or two parallel planes that cut it. A right circular cone is shown below:<\/p>\n After being cut by a plane parallel to its base, the right circular cone produces the following frustum:<\/p>\n which has a circular base with radius R at the bottom, a circular upper portion with radius R height h, and a slant height l.<\/p>\n Formulas:<\/strong><\/p>\n volume of the frustum of a cone = 1\/3 * pi * h(r2<\/sup> + R2<\/sup> + r*R)<\/p>\n The curved surface area of a frustum of a cone = pi * l(R+r)<\/p>\n The total surface area of a frustum of a cone = pi * l(R+r) + pi(R2<\/sup> + r2<\/sup>)<\/p>\n In which,<\/p>\n r<\/strong> is the radius of the smaller circle<\/p>\n R<\/strong> is the radius of the bigger circle<\/p>\n l<\/strong> is the slant height of the frustum of a cone.<\/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 find the volume and surface area of the frustum of a given cone 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 height, slant height, smaller and bigger radius of a frustum cone, the task is to find the volume and surface area of the frustum of a given cone in python. Frustum of a Cone : A frustum in geometry is the portion of a solid (typically a cone or pyramid) that lies between …<\/p>\n
\nThe portion of a solid between a plane parallel to the base and a right circular cone is known as the frustum of a cone.<\/p>\nGiven smaller radius = 3\r\nGiven bigger radius = 6\r\nGiven slant height = 8\r\nGiven height = 10<\/pre>\n
The Volume of above given Frustum of Cone = 659.7344572538565\r\nThe curved surface area of the above given frustum of Cone = 226.1946710584651\r\nThe total surface area of the above given frustum of Cone : 367.5663404700058<\/pre>\n
Given smaller radius = 4\r\nGiven bigger radius = 7\r\nGiven slant height = 10\r\nGiven height = 15<\/pre>\n
The Volume of above given Frustum of Cone = 1460.8405839192537\r\nThe curved surface area of the above given frustum of Cone = 345.57519189487726\r\nThe total surface area of the above given frustum of Cone : 549.7787143782139<\/pre>\n
Program for Volume and Surface Area of Frustum of Cone 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# Get the value of pi using the math.pi function and store it in a variable.\r\npi_val = math.pi\r\n# Give the radius of the smaller circle as static input and store it in a variable.\r\ngvn_smallrradiuss = 3\r\n# Give the radius of the bigger circle as static input and store it in another variable.\r\ngvn_biggradiuss = 6\r\n# Give the slant height of the frustum cone as static input and store it in\r\n# another variable.\r\ngvn_slantheigt = 8\r\n# Give the height as static input and store it in another variable.\r\ngvn_heigt = 10\r\n# Calculate the volume of the frustum of a cone using the above given mathematical\r\n# formula and store it in another variable.\r\nrslt_vol = 1 \/ 3 * pi_val * gvn_heigt * \\\r\n (gvn_smallrradiuss * gvn_smallrradiuss + gvn_biggradiuss *\r\n gvn_biggradiuss + gvn_smallrradiuss * gvn_biggradiuss)\r\n# Calculate the curved surface area of a frustum of a cone using the above given\r\n# mathematical formula and store it in another variable.\r\ncurvd_surfce_area = pi_val * gvn_slantheigt * \\\r\n (gvn_biggradiuss + gvn_smallrradiuss)\r\n# Calculate the total surface area of a frustum of a cone using the above given\r\n# mathematical formula and store it in another variable.\r\ntotl_surfce_area = pi_val * gvn_slantheigt * (gvn_biggradiuss + gvn_smallrradiuss) + pi_val * \\\r\n (gvn_smallrradiuss * gvn_smallrradiuss + gvn_biggradiuss * gvn_biggradiuss)\r\n# Print the volume of the frustum of a cone.\r\nprint(\"The Volume of above given Frustum of Cone = \", rslt_vol)\r\n# Print the curved surface area of a frustum of a cone.\r\nprint(\"The curved surface area of the above given frustum of Cone = \", curvd_surfce_area)\r\n# Print the Total surface area of a frustum of a cone.\r\nprint(\"The total surface area of the above given frustum of Cone : \", totl_surfce_area)\r\n<\/pre>\n
#include <cmath>\r\n#include <iostream>\r\n\r\nusing namespace std;\r\n\r\nint main()\r\n{\r\n int argc = 2;\r\n double pi_val = M_PI;\r\n double gvn_smallrradiuss = 3;\r\n int gvn_biggradiuss = 6;\r\n int gvn_slantheigt = 8;\r\n int gvn_heigt = 10;\r\n double rslt_vol\r\n = 1 \/ 3 * pi_val * gvn_heigt\r\n * (gvn_smallrradiuss * gvn_smallrradiuss\r\n + gvn_biggradiuss * gvn_biggradiuss\r\n + gvn_smallrradiuss * gvn_biggradiuss);\r\n double curvd_surfce_area\r\n = pi_val * gvn_slantheigt\r\n * (gvn_biggradiuss + gvn_smallrradiuss);\r\n double totl_surfce_area\r\n = pi_val * gvn_slantheigt\r\n * (gvn_biggradiuss + gvn_smallrradiuss)\r\n + pi_val * gvn_smallrradiuss * gvn_smallrradiuss\r\n + gvn_biggradiuss * gvn_biggradiuss;\r\n \/\/ Print the volume of the frustum of a cone.\r\n cout << \"The Volume of above given Frustum of Cone = \"\r\n << rslt_vol << endl;\r\n \/\/ Print the curved surface area of a frustum of a cone.\r\n cout << \"The curved surface area of the above given \"\r\n \"frustum of Cone = \"\r\n << curvd_surfce_area << endl;\r\n \/\/ Print the Total surface area of a frustum of a cone.\r\n cout << \"The total surface area of the above given \"\r\n \"frustum of Cone :\"\r\n << totl_surfce_area;\r\n}<\/pre>\n
The Volume of above given Frustum of Cone = 659.7344572538565\r\nThe curved surface area of the above given frustum of Cone = 226.1946710584651\r\nThe total surface area of the above given frustum of Cone : 367.5663404700058<\/pre>\n
Method #2: Using Mathematical Formula (User Input)<\/h3>\n
\n
# Import math module using the import keyword.\r\nimport math\r\n# Get the value of pi using the math.pi function and store it in a variable.\r\npi_val = math.pi\r\n# Give the radius of the smaller circle as user input using the float(input()) function\r\n# and store it in a variable.\r\ngvn_smallrradiuss = float(input(\"Enter some random number = \"))\r\n# Give the radius of the bigger circle as user input using the float(input()) function \r\n# and store it in another variable.\r\ngvn_biggradiuss = float(input(\"Enter some random number = \"))\r\n# Give the slant height of the frustum cone as user input using the float(input()) function\r\n# and store it in another variable.\r\ngvn_slantheigt = float(input(\"Enter some random number = \"))\r\n# Give the height as user input using the float(input()) function and\r\n# store it in another variable.\r\ngvn_heigt = float(input(\"Enter some random number = \"))\r\n# Calculate the volume of the frustum of a cone using the above given mathematical\r\n# formula and store it in another variable.\r\nrslt_vol = 1 \/ 3 * pi_val * gvn_heigt * \\\r\n (gvn_smallrradiuss * gvn_smallrradiuss + gvn_biggradiuss *\r\n gvn_biggradiuss + gvn_smallrradiuss * gvn_biggradiuss)\r\n# Calculate the curved surface area of a frustum of a cone using the above given\r\n# mathematical formula and store it in another variable.\r\ncurvd_surfce_area = pi_val * gvn_slantheigt * \\\r\n (gvn_biggradiuss + gvn_smallrradiuss)\r\n# Calculate the total surface area of a frustum of a cone using the above given\r\n# mathematical formula and store it in another variable.\r\ntotl_surfce_area = pi_val * gvn_slantheigt * (gvn_biggradiuss + gvn_smallrradiuss) + pi_val * \\\r\n (gvn_smallrradiuss * gvn_smallrradiuss + gvn_biggradiuss * gvn_biggradiuss)\r\n# Print the volume of the frustum of a cone.\r\nprint(\"The Volume of above given Frustum of Cone = \", rslt_vol)\r\n# Print the curved surface area of a frustum of a cone.\r\nprint(\"The curved surface area of the above given frustum of Cone = \", curvd_surfce_area)\r\n# Print the Total surface area of a frustum of a cone.\r\nprint(\"The total surface area of the above given frustum of Cone : \", totl_surfce_area)\r\n<\/pre>\n
Enter some random number = 4\r\nEnter some random number = 7\r\nEnter some random number = 10\r\nEnter some random number = 15\r\nThe Volume of above given Frustum of Cone = 1460.8405839192537\r\nThe curved surface area of the above given frustum of Cone = 345.57519189487726\r\nThe total surface area of the above given frustum of Cone : 549.7787143782139<\/pre>\n