# Find the volume of the ellipsoid – Python Program to Calculate Volume of Ellipsoid

Find the volume of the ellipsoid: In the previous article, we have discussed Python Program for Maximize Volume of Cuboid with Given Sum of Sides
Given the three radius values of an ellipsoid and the task is to calculate the volume of a given ellipsoid in python.

Ellipsoid :

Ellipsoid is a closed surface whose plane cross-sections are all ellipses or circles. An ellipsoid has three mutually perpendicular axes that intersect at the center. It is a three-dimensional, closed geometric shape with all of its planar sections being ellipses or circles.

An ellipsoid has three independent axes and is usually defined by the lengths of the three semi-axes, a, b, and c. If an ellipsoid is formed by rotating an ellipse about one of its axes, the ellipsoid’s two axes are the same, and it is known as an ellipsoid of revolution or spheroid. It is a sphere if the lengths of all three of its axes are the same.

Formula:

Volume = (4/3) * pi * r1 * r2 * r3

where pi = 3.1415…

Examples:

Example1:

Input:

Given first radius = 1
Given third radius = 6.5

Output:

The Volume of given ellipsoid with given radii { 1 3 6.5 } =  81.4772054708513

Example2:

Input:

Given first radius = 2
Given third radius = 8

Output:

The Volume of given ellipsoid with given radii { 2 4.5 8 } =  300.8389125077586

## Program to Calculate Volume of Ellipsoid in Python

Below are the ways to calculate the volume of a given ellipsoid in python:

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

Approach:

• Import math module using the import keyword.
• Give the first radius as static input and store it in a variable.
• Give the second radius as static input and store it in another variable.
• Give the third radius as static input and store it in another variable.
• Create a function to say Ellipsoid_volume() which takes the given three radii as the arguments and returns the volume of a given ellipsoid.
• Inside the function, calculate the volume of the ellipsoid using the above given mathematical formula, math. pi and store it in a variable.
• Return the above result.
• Pass the given three radii as the arguments to the Ellipsoid_volume() function and print it.
• The Exit of the Program.

Below is the implementation:

# Import math module using the import keyword.
import math

# Create a function to say Ellipsoid_volume() which takes the given three radii as
# the arguments and returns the volume of a given ellipsoid.

# Inside the function, calculate the volume of the ellipsoid using the above given
# mathematical formula, math.pi and store it in a variable.
# Return the above result.
return rslt_vol

# Give the first radius as static input and store it in a variable.
# Give the second radius as static input and store it in another variable.
# Give the third radius as static input and store it in another variable.
# Pass the given three radii as the arguments to the Ellipsoid_volume() function
# and print it.

#include <iostream>
#include <cmath>

using namespace std;

int main() {
cout << "The Volume of given ellipsoid with given radii {" << fst_radiuss << ", " << scnd_radiuss << ", " << thrd_radiuss << "} = " << rslt_vol << rslt_vol;

}

Output:

The Volume of given ellipsoid with given radii { 1 3 6.5 } =  81.4772054708513

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

Approach:

• Import math module using the import keyword.
• Give the first radius as user input using the float(input()) function and store it in a variable.
• Give the second radius as user input using the float(input()) function and store it in another variable.
• Give the third radius as user input using the float(input()) function and store it in another variable.
• Create a function to say Ellipsoid_volume() which takes the given three radii as the arguments and returns the volume of a given ellipsoid.
• Inside the function, calculate the volume of the ellipsoid using the above given mathematical formula, math. pi and store it in a variable.
• Return the above result.
• Pass the given three radii as the arguments to the Ellipsoid_volume() function and print it.
• The Exit of the Program.

Below is the implementation:

# Import math module using the import keyword.
import math

# Create a function to say Ellipsoid_volume() which takes the given three radii as
# the arguments and returns the volume of a given ellipsoid.

# Inside the function, calculate the volume of the ellipsoid using the above given
# mathematical formula, math.pi and store it in a variable.
# Return the above result.
return rslt_vol

# Give the first radius as user input using the float(input()) function and
# store it in a variable.
fst_radiuss = float(input("Enter some random number = "))
# Give the second radius as user input using the float(input()) function and
# store it in another variable.
scnd_radiuss = float(input("Enter some random number = "))
# Give the third radius as user input using the float(input()) function and
# store it in another variable.
thrd_radiuss = float(input("Enter some random number = "))
# Pass the given three radii as the arguments to the Ellipsoid_volume() function
# and print it.

Enter some random number = 2
The Volume of given ellipsoid with given radii { 2.0 4.5 8.0 } = 300.8389125077586