This code snippet demonstrates how to calculate the volume and surface area of a cube using simple functions in Python.
def getVolume(a):
volume = a * a * a
return volume
def getSurface(a):
surface = 6 * a * a
return surface
edgeLength = int(input("Please enter the edge length: "))
print("Volume: " + repr(getVolume(edgeLength)))
print("Surface: " + repr(getSurface(edgeLength)))
Please enter the edge length: 5
Volume: 125
Surface: 150
getVolume(a)
def getVolume(a):
volume = a * a * a
return volume
a
, which represents the edge length of the cube.getSurface(a)
def getSurface(a):
surface = 6 * a * a
return surface
a
, which represents the edge length of the cube.edgeLength = int(input("Please enter the edge length: "))
print("Volume: " + repr(getVolume(edgeLength)))
print("Surface: " + repr(getSurface(edgeLength)))
input("Please enter the edge length: ")
.int()
, and this value is stored in the variable edgeLength
.getVolume()
function is called with edgeLength
as an argument, and the result is printed.getSurface()
function is called with edgeLength
as an argument, and the result is printed.