Skip to content

Commit

Permalink
Merge pull request #74 from NeuroHackademy2024/20-update-spherepy-fun…
Browse files Browse the repository at this point in the history
…ction

add a function to calculate volume #20
  • Loading branch information
atambay37 authored Aug 5, 2024
2 parents 18e476a + 3732df7 commit eb26c23
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/geometry/sphere.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,35 @@
from math import pi


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

volume = (4 * pi * r **3) / 3
return volume


def calculate_surface_area(r):
"""
Calculate the surface area of a sphere.
This uses the standard mathematical calculation:
$4\pi r ^2$
float : the surface area of the sphere
"""
surface_area = 4 * pi * r **2
Expand Down

0 comments on commit eb26c23

Please sign in to comment.