From 5be3462ee1b6290fe0d8b5c0e83281779b68e777 Mon Sep 17 00:00:00 2001 From: Sophia Mehdizadeh Date: Mon, 5 Aug 2024 16:50:00 +0000 Subject: [PATCH] add a function to calculate volume --- src/geometry/sphere.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/geometry/sphere.py b/src/geometry/sphere.py index e69de29..f28f307 100644 --- a/src/geometry/sphere.py +++ b/src/geometry/sphere.py @@ -0,0 +1,22 @@ +from math import pi + + +def calculate_volume(r): + """ + Calculate the volume of a sphere. + + This uses the standard mathematical calculation: + + $(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 \ No newline at end of file