In this article we will show you, How to write Python Program to find Volume and Surface area of Sphere with example. Before we step into the program, Let see the definitions and formulas behind Surface area of Sphere and Volume of Sphere

### Surface Area of Sphere

A Sphere looks like a basketball or we can say the three-dimensional view of a circle. If we know the radius of the Sphere then we can calculate the Surface Area of Sphere using formula:

Surface Area of a Sphere = 4πr² (Where r is radius of the sphere).

From the above formula, If we know the Surface Area of a sphere then we can calculate the radius of a Sphere using the formula:

Radius of a Sphere = √sa / 4π (Where sa is the Surface Area of a sphere).

### Volume of Sphere

Amount of space inside the sphere is called as Volume. If we know the radius of the Sphere then we can calculate the Volume of Sphere using formula:

Volume of a Sphere = 4πr³

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

We defined pi as global variable and assigned value as 3.14. This program allows user to enter the value of a radius and then it will calculate the Surface Area and Volume of a Sphere as per the formula.

**CODE**

1 2 3 4 5 6 7 8 9 |
# Python Program to find Volume and Surface Area of Sphere PI = 3.14 radius = float(input('Please Enter the Radius of a Sphere: ')) sa = 4 * PI * radius * radius Volume = (4 / 3) * PI * radius * radius * radius print("\n The Surface area of a Sphere = %.2f" %sa) print("\n The Volume of a Sphere = %.2f" %Volume) |

**OUTPUT**

**ANALYSIS**

We have entered the Radius of a Sphere = 5

The **Surface Area of a Sphere** is

Surface Area = 4πr²

Surface Area = 4 * PI * radius * radius;

Surface Area = 4 * 3.14 * 5 * 5

Surface Area = 314

The **Volume of a Sphere** is

Volume = 4πr³

Volume = (4.0 / 3) * PI * radius * radius * radius;

Volume = (4.0 / 3) * 3.14 * 5 * 5 * 5;

Volume = 523.33333

Let us calculate the **Radius of a Sphere** using the Surface Area:

In the above example we got Surface area of a Sphere = 314 when the radius = 5. Let us do the reverse approach (Calculate the radius from Surface area = 5)

radius of a Sphere = √sa / 4π

radius of a Sphere = √314 / 4 * 3.14

radius of a Sphere = √314 / 12.56

radius of a Sphere = √25

radius of a Sphere = 5

## Python Program to find Volume and Surface Area of Sphere using functions

This program allows user to enter the value of a radius. We will pass the radius value to the function argument and then it will calculate the Surface Area and Volume of a Sphere as per the formula.

**PYTHON CODE**

1 2 3 4 5 6 7 8 9 10 11 |
# Python Program to find Volume and Surface Area of Sphere using Functions import math def Area_of_Triangle(radius): sa = 4 * math.pi * radius * radius Volume = (4 / 3) * math.pi * radius * radius * radius print("\n The Surface area of a Sphere = %.2f" %sa) print("\n The Volume of a Sphere = %.2f" %Volume) Area_of_Triangle(6) |

**OUTPUT**

**ANALYSIS**

First, We imported the math library using the following statement. This will allow us to use the mathematical functions like math.pi

1 |
import math |

Step 2: Next, We defined the function with one argument using def keyword. It means, User will enter the radius of a sphere.

Step 3: Calculating the Surface Area and Volume of a Sphere as per the formula

**NOTE:** Please be careful while placing the open and close brackets, it may change the entire calculation if you place it wrong

Thank You for Visiting Our Blog

## Share your Feedback, or Code!!