Write Python Program to find Volume and Surface Area of a Cube with example. Before we step into the Python Program to find Volume and Surface Area of a Cube, Let see the definitions and formulas

## Python Cube

All the edges in the Cube has same length. OR We can say, Cube is nothing but 6 equal squares.

### Surface Area of a Cube

If we know the length of any edge in Cube then we can calculate the surface area of a Cube using the formula:

Surface Area of a Cube = 6l² (Where l is the Length of any side of a Cube).

Area of a square = l² Since the Cube is made of 6 equal squares, Surface Area of a Cube = 6l²

If we already know the Surface Area of Cube. And then, we can calculate the length of any side by altering the above Python formula as:

l = √sa / 6 (sa = Surface Area of a Cube)

**Volume of a Cube**

The amount of space inside the Cube is called as Volume. If we know the length of any edge of a Cube then we can calculate the Volume of Cube using formula:

Volume = l * l * l

The Lateral Surface Area of a Cube = 4 * (l * l)

## Python Program to find Volume and Surface Area of a Cube

This python program allows user to enter any side of a Cube. Using this value, this Python program will calculate the Surface Area of a cube, Volume of a cube and Lateral Surface Area of a Cube as per the formulas.

# Python Program to find Volume and Surface Area of a Cube l = float(input('Please Enter the Length of any Side of a Cube: ')) sa = 6 * (l * l) Volume = l * l * l LSA = 4 * (l * l) print("\n Surface Area of Cube = %.2f" %sa) print(" Volume of cube = %.2f" %Volume) print(" Lateral Surface Area of Cube = %.2f" %LSA)

Within this Python Program to find Volume and Surface Area of a Cube, Below statements will ask the user to enter the length value and it will assign the user input values to respected variable.

l = float(input('Please Enter the Length of any Side of a Cube: '))

Next, We are calculating Volume, Surface Area and Lateral Surface Area of a Cube using their respective Formulas:

sa = 6 * (l * l) Volume = l * l * l LSA = 4 * (l * l)

Following print statements will help us to print the Volume, Lateral Surface Area and Surface area of a Cube

print("\n Surface Area of Cube = %.2f" %sa) print(" Volume of cube = %.2f" %Volume) print(" Lateral Surface Area of Cube = %.2f" %LSA)

In this Python Program to find Volume and Surface Area of a Cube example, We entered the Length of any side of a Cube = 5

The **Surface Area of a Cube** is

Surface Area of a cube = 6 * length * length => 6 * 5 * 5

Surface Area of a cube = 150

The **Volume of a Cube** is

Volume of a cube = length * length * length => 5 * 5 * 5

Volume of a cube = 125

The **Lateral Surface Area of a Cube** is

Lateral Surface Area of a cube = 4 * length * length => 4 * 5 * 5

Lateral Surface Area of a cube = 100

In the above example we got Surface area = 150 when the length = 5. Let us do the reverse approach (Calculate the length of a Cube using Surface Area = 150)

Length of a cube = √sa / 6 => √150 / 6

Length of a cube = √25 => 5

## Python Program to find Volume and Surface Area of a Cube using functions

This python program allows user to enter any side of a Cube. We will pass the value to the function argument and then it will calculate the Surface Area of a Cube, Lateral Surface Area of a Cube and Volume of a Cube as per the formula.

# Python Program to find Volume and Surface Area of a Cube Using Functions def Vo_Sa_Cone(l): sa = 6 * (l * l) Volume = l * l * l LSA = 4 * (l * l) print("\n Surface Area of Cube = %.2f" %sa) print(" Volume of cube = %.2f" %Volume) print(" Lateral Surface Area of Cube = %.2f" %LSA) Vo_Sa_Cone(6)

First, We defined the function with one argument using def keyword. It means, User will enter the length of a cube. Next, We are calculating the Surface Area of a Cube, Lateral Surface Area of a Cube and Volume of a Cube as per the formula

**NOTE:** We can call the function with arguments in .py file directly or else we can call it from the python shell. Please don’t forget the function arguments