 # Python Program to Find Volume and Surface Area of Sphere

In the previous article, we have discussed Python Program to Find Volume and Surface Area of a Cube
Given the radius and the task is to find the volume and surface area of the given sphere.

Surface Area of the sphere:

A sphere resembles a basketball or the three-dimensional view of a circle. If we know the radius of the Sphere,

we can use the following formula to calculate the Surface Area of the Sphere:

The Surface Area of a Sphere = 4πr²

r= radius of the given sphere

The Volume of the sphere:

Volume is the amount of space inside the sphere. If we know the radius of the sphere, we can use the following formula to calculate the volume of the sphere:

The volume of a Sphere = 4πr³

Examples:

Example 1:

Input:

Given radius = 7.5

Output:

The Surface area of the given Sphere with the radius [ 7.5 ]= 706.500
The volume of the given Sphere with the radius [ 7.5 ]= 1766.250

Example 2:

Input:

Given radius = 3

Output:

The Surface area of the given Sphere with the radius [ 3 ]= 113.040
The volume of the given Sphere with the radius [ 3 ]= 113.040

## Program to Find Volume and Surface Area of Sphere

Below are the ways to find the volume and surface area of the given sphere:

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

Approach:

• Give the radius of a sphere as static input and store it in a variable.
• Take a variable and initialize it with the “pi” value i.e. 3.14 and store it in another variable.
• Calculate the surface area of the given sphere using the above mathematical formula and store it in another variable.
• Calculate the volume of the given sphere using the above mathematical formula and store it in another variable.
• Print the surface area of the given sphere.
• Print the volume of the given sphere.
• The Exit of the Program.

Below is the implementation:

# Give the radius of a sphere  as static input and store it in a variable.
# Take a variable and initialize it with the "pi" value i.e. 3.14 and
# store it in another variable.
standard_pi_val = 3.14
# Calculate the surface area of the given sphere using the above mathematical formula
# and store it in another variable.
# Calculate the volume of the given sphere using the above mathematical formula and
# store it in another variable.
# Print the surface area of the given sphere.
print(
"The Surface area of the given Sphere with the radius [", gvn_radis, "]= %.3f" % surf_area)
# Print the volume of the given sphere.
print(
"The volume of the given Sphere with the radius [", gvn_radis, "]= %.3f" % sphre_volm)


Output:

The Surface area of the given Sphere with the radius [ 7.5 ]= 706.500
The volume of the given Sphere with the radius [ 7.5 ]= 1766.250

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

Approach:

• Give the radius of a sphere as user input using the float(input()) function and store it in a variable
• Take a variable and initialize it with the “pi” value i.e. 3.14 and store it in another variable.
• Calculate the surface area of the given sphere using the above mathematical formula and store it in another variable.
• Calculate the volume of the given sphere using the above mathematical formula and store it in another variable.
• Print the surface area of the given sphere.
• Print the volume of the given sphere.
• The Exit of the Program.

Below is the implementation:

# Give the radius of a sphere as user input using the float(input()) function
# and store it in a variable
gvn_radis = float(input("Enter some random variable = "))
# Take a variable and initialize it with the "pi" value i.e. 3.14 and
# store it in another variable.
standard_pi_val = 3.14
# Calculate the surface area of the given sphere using the above mathematical formula
# and store it in another variable.
# Calculate the volume of the given sphere using the above mathematical formula and
# store it in another variable.
# Print the surface area of the given sphere.
print(
"The Surface area of the given Sphere with the radius [", gvn_radis, "]= %.3f" % surf_area)
# Print the volume of the given sphere.
print(
"The volume of the given Sphere with the radius [", gvn_radis, "]= %.3f" % sphre_volm)


Output:

Enter some random variable = 9
The Surface area of the given Sphere with the radius [ 9.0 ]= 1017.360
The volume of the given Sphere with the radius [ 9.0 ]= 3052.080

Explore more instances related to python concepts from Python Programming Examples Guide and get promoted from beginner to professional programmer level in Python Programming Language.