{"id":18020,"date":"2021-08-26T10:42:22","date_gmt":"2021-08-26T05:12:22","guid":{"rendered":"https:\/\/python-programs.com\/?p=18020"},"modified":"2021-11-22T18:37:13","modified_gmt":"2021-11-22T13:07:13","slug":"python-program-to-find-volume-and-surface-area-of-a-cuboid","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-find-volume-and-surface-area-of-a-cuboid\/","title":{"rendered":"Python Program to Find Volume and Surface Area of a Cuboid"},"content":{"rendered":"
In the previous article, we have discussed Python Program to Sort words in Alphabetic Order<\/a> A Cuboid is a three-dimensional object made up of six Rectangles. All of the opposing faces (Top and Bottom) are the same.<\/p>\n A Cuboid’s Surface Area :\u00a0<\/strong><\/p>\n The Total Surface Area of a Cuboid is the sum of the areas of the Cuboid’s six rectangles. If we know the Cuboid’s length, width, and height<\/strong>, we can use the formula to calculate its Total Surface Area:<\/p>\n Top and bottom surface area = lw + lw = 2lw<\/p>\n Front and back surface area = lh + lh = 2lh<\/p>\n Both sides’ area = wh + wh = 2wh<\/p>\n A Cuboid’s Total Surface Area is the sum of its six faces. So, in order to calculate the final Surface Area, we must add all of these areas together.<\/p>\n A Cuboid’s Total Surface Area = 2lw + 2lh + 2wh<\/p>\n It is the same as:<\/p>\n Formula for Surface Area of a cuboid = 2 (lw + lh + wh).<\/strong><\/p>\n A Cuboid’s Volume :<\/strong> Cuboid Volume = Length * Breadth * Height<\/p>\n A Cuboid’s Volume = lbh<\/p>\n A Cuboid’s Lateral Surface Area = 2h (l + w).<\/p>\n Given the length, width, and height <\/strong>of a cuboid, the task is to calculate the volume and surface of a given cuboid.<\/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 calculate the volume and surface of a given cuboid.<\/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 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 Sort words in Alphabetic Order Cuboid: A Cuboid is a three-dimensional object made up of six Rectangles. All of the opposing faces (Top and Bottom) are the same. A Cuboid’s Surface Area :\u00a0 The Total Surface Area of a Cuboid is the sum of the …<\/p>\n
\nCuboid:<\/strong><\/p>\n
\nVolume is the amount of space inside the Cuboid. If we know the Cuboid’s length, width, and height, we can use the following formula to calculate its volume:<\/p>\nGiven length = 1\r\nGiven width = 2\r\nGiven height = 3<\/pre>\n
The given surface Area of a Cuboid with given length,width,height[ 1 2 3 ]= 22.000\r\nThe given volume of a Cuboid with given length,width,height[ 1 2 3 ]= 6.000\r\nThe given lateral surface Area of a Cuboid with given length,width,height[ 1 2 3 ]= 18.000<\/pre>\n
Given length = 2.5\r\nGiven width = 5\r\nGiven height = 3<\/pre>\n
The given surface Area of a Cuboid with given length,width,height[ 2.5 5.0 3.0 ]= 70.000\r\nThe given volume of a Cuboid with given length,width,height[ 2.5 5.0 3.0 ]= 37.500\r\nThe given lateral surface Area of a Cuboid with given length,width,height[ 2.5 5.0 3.0 ]= 45.000<\/pre>\n
Program to Find Volume and Surface Area of a Cuboid<\/h2>\n
\n
Method #1: Using Mathematical Formula (Static Input)<\/h3>\n
\n
# Give the length of a cuboid as static input and store it in a variable.\r\ngvn_len = 1\r\n# Give the width of a cuboid as static input and store it in another variable.\r\ngvn_widt = 2\r\n# Give the height of a cuboid as static input and store it in another variable.\r\ngvn_heigt = 3\r\n# Calculate the surface area of a given cuboid using the above given mathematical formula\r\n# and store it in another variable.\r\nsurf_area = 2 * (gvn_len * gvn_widt + gvn_len *\r\n gvn_heigt + gvn_widt * gvn_heigt)\r\n# Calculate the volume of a given cuboid using the above given mathematical formula\r\n# and store it in another variable.\r\nVol = gvn_len * gvn_widt * gvn_heigt\r\n# Calculate the lateral surface area of a given cuboid using the above given mathematical\r\n# formula and store it in another variable.\r\nLaterl_surfcarea = 2 * gvn_heigt * (gvn_len + gvn_widt)\r\n# Print the surface area of a given cuboid.\r\nprint(\r\n \"The given surface Area of a Cuboid with given length,width,height[\", gvn_len, gvn_widt, gvn_heigt, \"]= %.3f\" % surf_area)\r\n# Print the volume of a given cuboid.\r\nprint(\r\n \"The given volume of a Cuboid with given length,width,height[\", gvn_len, gvn_widt, gvn_heigt, \"]= %.3f\" % Vol)\r\n# Print the lateral surface area of a given cuboid.\r\nprint(\r\n \"The given lateral surface Area of a Cuboid with given length,width,height[\", gvn_len, gvn_widt, gvn_heigt, \"]= %.3f\" % Laterl_surfcarea)\r\n<\/pre>\n
The given surface Area of a Cuboid with given length,width,height[ 1 2 3 ]= 22.000\r\nThe given volume of a Cuboid with given length,width,height[ 1 2 3 ]= 6.000\r\nThe given lateral surface Area of a Cuboid with given length,width,height[ 1 2 3 ]= 18.000<\/pre>\n
Method #2: Using Mathematical Formula (User Input)<\/h3>\n
\n
# Give the length of a cuboid as user input using the float(input()) function and\r\n# store it in a variable.\r\ngvn_len = float(input(\"Enter some random number = \"))\r\n# Give the width of a cuboid as user input using the float(input()) function and\r\n# store it in another variable.\r\ngvn_widt = float(input(\"Enter some random number = \"))\r\n# Give the height of a cuboid as user input using the float(input()) function\r\n# and store it in another variable.\r\ngvn_heigt = float(input(\"Enter some random number = \"))\r\n# Calculate the surface area of a given cuboid using the above given mathematical formula\r\n# and store it in another variable.\r\nsurf_area = 2 * (gvn_len * gvn_widt + gvn_len *\r\n gvn_heigt + gvn_widt * gvn_heigt)\r\n# Calculate the volume of a given cuboid using the above given mathematical formula\r\n# and store it in another variable.\r\nVol = gvn_len * gvn_widt * gvn_heigt\r\n# Calculate the lateral surface area of a given cuboid using the above given mathematical\r\n# formula and store it in another variable.\r\nLaterl_surfcarea = 2 * gvn_heigt * (gvn_len + gvn_widt)\r\n# Print the surface area of a given cuboid.\r\nprint(\r\n \"The given surface Area of a Cuboid with given length,width,height[\", gvn_len, gvn_widt, gvn_heigt, \"]= %.3f\" % surf_area)\r\n# Print the volume of a given cuboid.\r\nprint(\r\n \"The given volume of a Cuboid with given length,width,height[\", gvn_len, gvn_widt, gvn_heigt, \"]= %.3f\" % Vol)\r\n# Print the lateral surface area of a given cuboid.\r\nprint(\r\n \"The given lateral surface Area of a Cuboid with given length,width,height[\", gvn_len, gvn_widt, gvn_heigt, \"]= %.3f\" % Laterl_surfcarea)\r\n<\/pre>\n
Enter some random number = 2.5\r\nEnter some random number = 5\r\nEnter some random number = 3\r\nThe given surface Area of a Cuboid with given length,width,height[ 2.5 5.0 3.0 ]= 70.000\r\nThe given volume of a Cuboid with given length,width,height[ 2.5 5.0 3.0 ]= 37.500\r\nThe given lateral surface Area of a Cuboid with given length,width,height[ 2.5 5.0 3.0 ]= 45.000<\/pre>\n
\n