Skip to content

Commit

Permalink
Update sphere.py
Browse files Browse the repository at this point in the history
Added calculation for volume of a sphere for issue #24
  • Loading branch information
meganhuibregtse authored Aug 5, 2024
1 parent b4641c1 commit 1a9a708
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/geometry/sphere.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from math import pi

def calculate_volume(r):
"""
Calculate the volume of a sphere.
This uses the standard mathematical calculation:
$\(4/3) pi r ^3$
Parameters
----------
r : float, the radius
Returns
-------
float : the volume of the sphere
"""
volume = (4/3) * pi * r **3
return volume

0 comments on commit 1a9a708

Please sign in to comment.