Programming Examples
Python program to input the radius of a sphere and calculate its volume
Write a program to input the radius of a sphere and calculate its volume (V = 4/3πr3)
Solution
import math
r = float(input("Enter radius of sphere: "))
v = 4 / 3 * math.pi * r ** 3
print("Volume of sphere = ", v)
Output
Enter radius of sphere: 3.5
Volume of sphere = 179.59438003021648