# Python program to calculate surface area and volume of a sphere

In this session, we are going to discuss the definition of the sphere and how to calculate the surface area as well as the volume of the sphere using Python.

## How to calculate  area and volume of a sphere in Python

Sphere:

A sphere is defined as the perfect geometrical shape in 3D space that looks like a completely round ball.on the other hand we can say that a sphere is a set of purposes that area unit all at constant distance r from a given point.

the formula for area of the sphere is :

```area of sphere =4πr²
where r is equal distance from a given point```

the formula for the volume of the sphere:

`volume of the sphere =(4/3)*πr³.`

1st we have to import the math package :

```#impotr math package to use math.pi for the value of PI
import math
```

Take the user input as a radius of the sphere:

```#take radius of the   sphere from user
r=float(input("Enter r of a sphere"))
```

Calculate the area and volume of  the sphere:

```#calculate the surface area of sphere
s_area=4*math.pi*pow(r,2)
#calculate the volume of sphere
volume=(4/3)*math.pi*pow(r,3)
```

Combine the whole program:

```#impotr math package to use math.pi for the value of PI
import math
#take radius of the   sphere from user
r=float(input("Enter the r of a sphere"))
#calculate the surface area of sphere
s_area=4*math.pi*pow(r,2)
#calculate the volume of sphere
volume=(4/3)*math.pi*pow(r,3)
#now printing the output
print("surface area of the sphere wll be %.2f" %s_area)
print("volume of the sphere will be  %.2f" %volume)
```

Output:

```Enter the Radius of a sphere: 5
surface area of the sphere wll be 314.16
volume of the sphere will be  523.60
```

Also learn: