# Python Program to Find Volume and Surface Area of Sphere

Howdy readers, today you will learn how to write a python program to find the volume and surface area of a sphere.

A sphere is a 3-dimensional solid figure which is round in shape. Examples of spheres are – Basketball, Football and Cricket Ball.

The volume and surface area of a sphere can be calculated using mathematical formulas if the radius of the sphere is given.

This program prompts the user to enter the radius of the sphere, then it calculates the volume and surface area using the following methods:

1. Using Basic Mathematics
2. Using pow()
3. Using Functions

So, without any delay, let’s begin this tutorial.

## Volume of Sphere

The volume of a sphere is the measure of the space that can be occupied in it. It is measured in cubic units. The formula to calculate the volume of a sphere is:

Volume of Sphere (V) = (4/3)πr3

where,

• V is the volume of the sphere
• r is the radius of the sphere
• π = 3.14 or 22/7

## Surface Area of Sphere

The area covered by the outer surface of the sphere is known as the surface area of a sphere. It is measured in square units. The formula to calculate the surface area of a sphere is:

Surface Area of Sphere (S) = 4πr2

where,

• S is the surface area of the sphere
• r is the radius of the sphere
• π = 3.14 or 22/7

## Python Program to Find Volume and Surface Area of Sphere

Python Program

```# Python Program to Find Volume and Surface Area of Sphere

# User Input
PI = 3.14

# Surface Area Sphere

# Volume of Sphere

# Display Volume and Surface Area of the Sphere
print("The volume of the sphere is: ", vol)
print("The surface area of the sphere is: ", SA)
```

Output

```Enter the radius of the sphere: 7
The volume of the sphere is:  1436.0266666666666
The surface area of the sphere is:  615.44
```

Explanation

```PI = 3.14
```

The PI variable has been assigned a value of 3.14 and the user input is stored in the radius variable.

```SA = 4 * PI * radius * radius
```

Now, the surface area of the sphere is calculated using the mathematical formula, Surface Area of Sphere (S) = 4πr2.

The surface area is stored in the SA variable.

```vol = (4/3) * PI * radius * radius * radius
```

Similarly, the volume of the sphere is calculated using the formula, Volume of Sphere (V) = (4/3)πr3

```print("Volume of the sphere is: ", vol)
print("Surface area of the sphere is: ", SA)
```

The volume and surface area of the sphere which is stored in vol and SA variables is printed on the screen using the print() function.

## Python Program to Find Volume and Surface Area of Sphere Using pow()

Python Program

```# Python Program to Calculate Volume and Surface Area of Sphere Using math Module
import math

# User input
r = float(input("Enter the radius of a sphere: "))

# Calculate Volume
volume = (4/3) * math.pi * pow(r, 3)

# Calculate Surface Area
area = 4 * math.pi * pow(r, 2)

# Display Result
print("The volume of the sphere is: ", volume)
print("The surface area of the sphere is: ", area)

```

Output

```Enter the radius of the circle: 14
The volume of the sphere is:  11494.040321933855
The surface area of the sphere is:  2463.0086404143976
```

Explanation

```import math
```

First, we import the math module into the program.

```r = float(input("Enter the radius of a sphere: "))
```

The value of the radius of the sphere entered by the user is stored in the r variable.

```volume = (4/3) * math.pi * pow(r, 3)
```

Now, the volume of the sphere is calculated using the formula, Volume = (4/3)πr3. The computed value is stored in the volume variable.

Here, we use pow() to calculate the value of r3.

The pow() function returns the value of x to the power y.

Syntax

```pow(a, b) = ab
```

Similarly, the surface area of the sphere is calculated. The surface area of the sphere is stored in the area variable.

## Python Program to Find Volume and Surface Area of Sphere Using Functions

Python Program

```# Python Program to Find Volume and Surface Area of Sphere Using Functions
import math

def volumeArea(r):
SA = 4 * math.pi * pow(r, 2)
V = (4/3) * math.pi * pow(r, 3)
print("The volume of the sphere is: %.2f" %V)
print("The surface area of the sphere is: %.2f" %SA)

```

Output

```Enter the radius of the sphere: 3
The volume of the sphere is: 113.10
The surface area of the sphere is: 113.10
```

Explanation

```def volumeArea(r):
SA = 4 * math.pi * pow(r, 2)
V = (4/3) * math.pi * pow(r, 3)
print("The volume of the sphere is: %.2f" %V)
print("The surface area of the sphere is: %.2f" %SA)
```

We have declared a function volArea which passes the radius of the sphere as an argument and returns the volume and surface area of the sphere.

```volumeArea(radius)
```

Then, this function is called in the main function. This prints the measure of volume and surface area of the sphere on the screen.

## Conclusion

Today you learned how to write a python program to find the volume and surface area of a sphere.

You learnt three different methods to calculate the volume and surface area of the sphere, you can use any of the methods to get the desired result.

If you have any queries related to the tutorial, comment down your doubts in the comment section.