Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 40 additions & 21 deletions src/geometry/sphere.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,40 @@
from math import pi


def calculate_surface_area(r):
"""
Calculate the surface area of a sphere.

This uses the standard mathematical calculation:

$4\pi r ^2$

Parameters
----------
r : float, the radius

Returns
-------
float : the surface area of the sphere
"""
surface_area = 4 * pi * r **2
return surface_area
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


def calculate_surface_area(r):
"""
Calculate the surface area of a sphere.

This uses the standard mathematical calculation:

$4\pi r ^2$

Parameters
----------
r : float, the radius

Returns
-------
float : the surface area of the sphere
"""
surface_area = 4 * pi * r **2
return surface_area