How to write Python Program to find Volume and Surface area of Sphere with example. Before we step into the Python Program to find Volume and Surface Area of Sphere, Let see the definitions and formulas

### Python 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).

### Python 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 python 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.

# 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**

Within this Python Program to find Volume and Surface Area of Sphere, 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 Python 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 python 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 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**

In this Python Program to find Volume and Surface Area of Sphere, First, We imported the math library using the following statement. This will allow us to use the mathematical functions like math.pi

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