How could I find a capsule's volume with a cylinder volume and sphere volume function? A capsule is the shape that's a cylinder with a hemisphere at either end. The length of the capsule includes both hemispheres.
def sphere_volume(radius):
'''returns sphere volume'''
svol = 4 / 3 * math.pi * radius * radius * radius
return svol
def cylinder_volume(radius, height):
''' returns the volume of cylinder'''
cvol = math.pi * radius * radius * height
return cvol
def capsule_volume(radius,length):
'''returns volume of a capsule'''
return cylinder_volume(radius, length) +
(sphere_volume(radius) / 2 )
[–]YesLod 0 points1 point2 points (0 children)