# Python Program to Find Volume and Surface Area of a Cuboid

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 :

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, we can use the formula to calculate its Total Surface Area:

Top and bottom surface area = lw + lw = 2lw

Front and back surface area = lh + lh = 2lh

Both sides’ area = wh + wh = 2wh

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.

A Cuboid’s Total Surface Area = 2lw + 2lh + 2wh

It is the same as:

Formula for Surface Area of a cuboid = 2 (lw + lh + wh).

A Cuboid’s Volume :
Volume 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:

Cuboid Volume = Length * Breadth * Height

A Cuboid’s Volume = lbh

A Cuboid’s Lateral Surface Area = 2h (l + w).

Given the length, width, and height of a cuboid, the task is to calculate the volume and surface of a given cuboid.

Examples:

Example 1:

Input:

Given length = 1
Given width = 2
Given height = 3

Output:

The given surface Area of a Cuboid with given length,width,height[ 1 2 3 ]= 22.000
The given volume of a Cuboid with given length,width,height[ 1 2 3 ]= 6.000
The given lateral surface Area of a Cuboid with given length,width,height[ 1 2 3 ]= 18.000

Example 2:

Input:

Given length = 2.5
Given width = 5
Given height = 3

Output:

The given surface Area of a Cuboid with given length,width,height[ 2.5 5.0 3.0 ]= 70.000
The given volume of a Cuboid with given length,width,height[ 2.5 5.0 3.0 ]= 37.500
The given lateral surface Area of a Cuboid with given length,width,height[ 2.5 5.0 3.0 ]= 45.000

## Program to Find Volume and Surface Area of a Cuboid

Below are the ways to calculate the volume and surface of a given cuboid.

### Method #1: Using Mathematical Formula (Static Input)

Approach:

• Give the length of a cuboid as static input and store it in a variable.
• Give the width of a cuboid as static input and store it in another variable.
• Give the height of a cuboid as static input and store it in another variable.
• Calculate the surface area of a given cuboid using the above given mathematical formula and store it in another variable.
• Calculate the volume of a given cuboid using the above given mathematical formula and store it in another variable.
• Calculate the lateral surface area of a given cuboid using the above given mathematical formula and store it in another variable.
• Print the surface area of a given cuboid.
• Print the volume of a given cuboid.
• Print the lateral surface area of a given cuboid.
• The Exit of the Program.

Below is the implementation:

# Give the length of a cuboid as static input and store it in a variable.
gvn_len = 1
# Give the width of a cuboid as static input and store it in another variable.
gvn_widt = 2
# Give the height of a cuboid as static input and store it in another variable.
gvn_heigt = 3
# Calculate the surface area of a given cuboid using the above given mathematical formula
# and store it in another variable.
surf_area = 2 * (gvn_len * gvn_widt + gvn_len *
gvn_heigt + gvn_widt * gvn_heigt)
# Calculate the volume of a given cuboid using the above given mathematical formula
# and store it in another variable.
Vol = gvn_len * gvn_widt * gvn_heigt
# Calculate the lateral surface area of a given cuboid using the above given mathematical
# formula and store it in another variable.
Laterl_surfcarea = 2 * gvn_heigt * (gvn_len + gvn_widt)
# Print the surface area of a given cuboid.
print(
"The given surface Area of a Cuboid with given length,width,height[", gvn_len, gvn_widt, gvn_heigt, "]= %.3f" % surf_area)
# Print the volume of a given cuboid.
print(
"The given volume of a Cuboid with given length,width,height[", gvn_len, gvn_widt, gvn_heigt, "]= %.3f" % Vol)
# Print the lateral surface area of a given cuboid.
print(
"The given lateral surface Area of a Cuboid with given length,width,height[", gvn_len, gvn_widt, gvn_heigt, "]= %.3f" % Laterl_surfcarea)


Output:

The given surface Area of a Cuboid with given length,width,height[ 1 2 3 ]= 22.000
The given volume of a Cuboid with given length,width,height[ 1 2 3 ]= 6.000
The given lateral surface Area of a Cuboid with given length,width,height[ 1 2 3 ]= 18.000

### Method #2: Using Mathematical Formula (User Input)

Approach:

• Give the length of a cuboid as user input using the float(input()) function and store it in a variable.
• Give the width of a cuboid as user input using the float(input()) function and store it in another variable.
• Give the height of a cuboid as user input using the float(input()) function and store it in another variable.
• Calculate the surface area of a given cuboid using the above given mathematical formula and store it in another variable.
• Calculate the volume of a given cuboid using the above given mathematical formula and store it in another variable.
• Calculate the lateral surface area of a given cuboid using the above given mathematical formula and store it in another variable.
• Print the surface area of a given cuboid.
• Print the volume of a given cuboid.
• Print the lateral surface area of a given cuboid.
• The Exit of the Program.

Below is the implementation:

# Give the length of a cuboid as user input using the float(input()) function and
# store it in a variable.
gvn_len = float(input("Enter some random number = "))
# Give the width of a cuboid as user input using the float(input()) function and
# store it in another variable.
gvn_widt = float(input("Enter some random number = "))
# Give the height of a cuboid as user input using the float(input()) function
# and store it in another variable.
gvn_heigt = float(input("Enter some random number = "))
# Calculate the surface area of a given cuboid using the above given mathematical formula
# and store it in another variable.
surf_area = 2 * (gvn_len * gvn_widt + gvn_len *
gvn_heigt + gvn_widt * gvn_heigt)
# Calculate the volume of a given cuboid using the above given mathematical formula
# and store it in another variable.
Vol = gvn_len * gvn_widt * gvn_heigt
# Calculate the lateral surface area of a given cuboid using the above given mathematical
# formula and store it in another variable.
Laterl_surfcarea = 2 * gvn_heigt * (gvn_len + gvn_widt)
# Print the surface area of a given cuboid.
print(
"The given surface Area of a Cuboid with given length,width,height[", gvn_len, gvn_widt, gvn_heigt, "]= %.3f" % surf_area)
# Print the volume of a given cuboid.
print(
"The given volume of a Cuboid with given length,width,height[", gvn_len, gvn_widt, gvn_heigt, "]= %.3f" % Vol)
# Print the lateral surface area of a given cuboid.
print(
"The given lateral surface Area of a Cuboid with given length,width,height[", gvn_len, gvn_widt, gvn_heigt, "]= %.3f" % Laterl_surfcarea)


Output:

Enter some random number = 2.5
Enter some random number = 5
Enter some random number = 3
The given surface Area of a Cuboid with given length,width,height[ 2.5 5.0 3.0 ]= 70.000
The given volume of a Cuboid with given length,width,height[ 2.5 5.0 3.0 ]= 37.500
The given lateral surface Area of a Cuboid with given length,width,height[ 2.5 5.0 3.0 ]= 45.000

Explore more instances related to python concepts from Python Programming Examples Guide and get promoted from beginner to professional programmer level in Python Programming Language.