{"id":18015,"date":"2021-08-26T10:42:18","date_gmt":"2021-08-26T05:12:18","guid":{"rendered":"https:\/\/python-programs.com\/?p=18015"},"modified":"2021-11-22T18:37:13","modified_gmt":"2021-11-22T13:07:13","slug":"python-program-to-find-volume-and-surface-area-of-a-cube","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-find-volume-and-surface-area-of-a-cube\/","title":{"rendered":"Python Program to Find Volume and Surface Area of a Cube"},"content":{"rendered":"
In the previous article, we have discussed Python Program to Find Sum of Arithmetic Progression Series<\/a> If we know the length of an edge in a Cube, we can use the following formula to calculate the surface area of a Cube:<\/p>\n Cube Surface Area = 6S\u00b2 <\/strong><\/p>\n In which\u00a0 S= length of any side of a Cube<\/p>\n A square’s area = S\u00b2. Surface Area of a Cube = 6S\u00b2\u00a0 because the Cube is made up of 6 equal squares.<\/p>\n The volume of a Cube :<\/strong><\/p>\n Volume refers to the amount of space inside the Cube. If we know the length of any edge of a Cube, we can use the following<\/p>\n Formula to calculate the Volume of the Cube:\u00a0<\/strong> S*S*S*<\/p>\n Examples:<\/strong><\/p>\n Example 1:<\/strong><\/p>\n Input:<\/strong><\/p>\n Output:<\/strong><\/p>\n Example 2:<\/strong><\/p>\n Input:<\/strong><\/p>\n Output:<\/strong><\/p>\n Below are the ways to find the surface area, volume, and lateral surface for a given side of a cube:<\/p>\n Approach:<\/strong><\/p>\n Output:<\/strong><\/p>\n Approach:<\/strong><\/p>\n \u00a0Below is the implementation:<\/strong><\/strong><\/p>\n Output:<\/strong><\/p>\n Explore more instances related to python concepts from\u00a0Python Programming Examples<\/a>\u00a0Guide and get promoted from beginner to professional programmer level in Python Programming Language.<\/p>\n In the previous article, we have discussed Python Program to Find Sum of Arithmetic Progression Series Surface Area of a Cube : If we know the length of an edge in a Cube, we can use the following formula to calculate the surface area of a Cube: Cube Surface Area = 6S\u00b2 In which\u00a0 S= …<\/p>\n
\nSurface Area of a Cube :<\/strong><\/p>\nGiven side length of a cube = 12<\/pre>\n
The given surface Area of a Cube with side length [ 12 ]= 864.000\r\nThe given volume of a Cube with side length [ 12 ]= 1728.000\r\nThe given lateral surface area of a Cube with side lngth [ 12 ]= 576.000<\/pre>\n<\/div>\n
Given side length of a cube = 4<\/pre>\n
The given surface Area of a Cube with side length [ 4 ]= 96.000\r\nThe given volume of a Cube with side length [ 4 ]= 64.000\r\nThe given lateral surface area of a Cube with side lngth [ 4 ]= 64.000<\/pre>\n
Program to Find Volume and Surface Area of a Cube in Python<\/h2>\n
\n
Method #1: Using Mathematical Formula (Static Input)<\/h3>\n
\n
# Give the length of the side of a cube as static input and store it in a variable.\r\ncube_side = 7\r\n# Calculate the surface area of a given cube using the above given mathematical formula\r\n# and store it in another variable.\r\nsurf_area = 6 * (cube_side * cube_side)\r\n# Calculate the volume of a given cube using the above given mathematical formula and\r\n# store it in another variable.\r\nVolum = cube_side * cube_side * cube_side\r\n# Calculate the lateral surface area of a given cube using the above given mathematical\r\n# formula and store it in another variable.\r\nLaterl_surfcarea = 4 * (cube_side * cube_side)\r\n# Print the surface area of a given cube.\r\nprint(\r\n \"The given surface Area of a Cube with side length [\", cube_side, \"]= %.3f\" % surf_area)\r\n# Print the volume of a given cube.\r\nprint(\r\n \"The given volume of a Cube with side length [\", cube_side, \"]= %.3f\" % Volum)\r\n# Print the lateral surface area of a given cube.\r\nprint(\r\n \"The given lateral surface area of a Cube with side lngth [\", cube_side, \"]= %.3f\" % Laterl_surfcarea)\r\n<\/pre>\n
The given surface Area of a Cube with side length [ 7 ]= 294.000\r\nThe given volume of a Cube with side length [ 7 ]= 343.000\r\nThe given lateral surface area of a Cube with side lngth [ 7 ]= 196.000<\/pre>\n<\/div>\n<\/div>\n<\/div>\n
Method #2: Using Mathematical Formula (User Input)<\/h3>\n
\n
# Give the length of the side of a cube as user input using the float(input()) function\r\n# and store it in a variable.\r\ncube_side = float(input(\"Enter some random number = \"))\r\n# Calculate the surface area of a given cube using the above given mathematical formula\r\n# and store it in another variable.\r\nsurf_area = 6 * (cube_side * cube_side)\r\n# Calculate the volume of a given cube using the above given mathematical formula and\r\n# store it in another variable.\r\nVolum = cube_side * cube_side * cube_side\r\n# Calculate the lateral surface area of a given cube using the above given mathematical\r\n# formula and store it in another variable.\r\nLaterl_surfcarea = 4 * (cube_side * cube_side)\r\n# Print the surface area of a given cube.\r\nprint(\r\n \"The given surface Area of a Cube with side length [\", cube_side, \"]= %.3f\" % surf_area)\r\n# Print the volume of a given cube.\r\nprint(\r\n \"The given volume of a Cube with side length [\", cube_side, \"]= %.3f\" % Volum)\r\n# Print the lateral surface area of a given cube.\r\nprint(\r\n \"The given lateral surface area of a Cube with side lngth [\", cube_side, \"]= %.3f\" % Laterl_surfcarea)\r\n<\/pre>\n
Enter some random number = 5.5\r\nThe given surface Area of a Cube with side length [ 5.5 ]= 181.500\r\nThe given volume of a Cube with side length [ 5.5 ]= 166.375\r\nThe given lateral surface area of a Cube with side lngth [ 5.5 ]= 121.000<\/pre>\n<\/div>\n<\/div>\n<\/div>\n
\n