find the surface area of a cube in python

To find the surface area of a cube in Python, we need to use the formula:

surface_area = 6 * side_length ** 2

where side_length is the length of one side of the cube.

We can write the following Python function that takes the side_length as an input parameter and returns the surface area of the cube:

main.py
def cube_surface_area(side_length):
    surface_area = 6 * side_length ** 2
    return surface_area
100 chars
4 lines

Here's how we can use this function to find the surface area of a cube with side length 5:

main.py
>>> cube_surface_area(5)
150
29 chars
3 lines

Therefore, the surface area of a cube with side length 5 is 150.

gistlibby LogSnag