From 098a1b23459072623e36a9f9a79095efb72d2837 Mon Sep 17 00:00:00 2001 From: Gopesh Pandey Date: Sat, 17 Jan 2026 01:53:12 +0530 Subject: [PATCH 1/9] Create volume_of_torus.py --- maths/volume_of_torus.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 maths/volume_of_torus.py diff --git a/maths/volume_of_torus.py b/maths/volume_of_torus.py new file mode 100644 index 000000000000..ff28d88e021e --- /dev/null +++ b/maths/volume_of_torus.py @@ -0,0 +1,26 @@ +""" +Volume of a Torus +Board: https://en.wikipedia.org/wiki/Torus +""" +import math + +def volume_of_torus(major_radius: float, minor_radius: float) -> float: + """ + Calculate the volume of a torus. + + :param major_radius: Distance from the center of the tube to the center of the torus (R) + :param minor_radius: Radius of the tube (r) + :return: Volume of the torus + + >>> volume_of_torus(3, 1) + 59.21762640653615 + >>> volume_of_torus(5, 2) + 394.7841760435743 + """ + if major_radius < 0 or minor_radius < 0: + raise ValueError("Radii must be non-negative") + return 2 * (math.pi ** 2) * major_radius * (minor_radius ** 2) + +if __name__ == "__main__": + import doctest + doctest.testmod() From cda24f7714ea12461fa2dc69e0f4bb8da4ce235e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 16 Jan 2026 20:33:19 +0000 Subject: [PATCH 2/9] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- maths/volume_of_torus.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/maths/volume_of_torus.py b/maths/volume_of_torus.py index ff28d88e021e..3f930f977b11 100644 --- a/maths/volume_of_torus.py +++ b/maths/volume_of_torus.py @@ -2,8 +2,10 @@ Volume of a Torus Board: https://en.wikipedia.org/wiki/Torus """ + import math + def volume_of_torus(major_radius: float, minor_radius: float) -> float: """ Calculate the volume of a torus. @@ -11,7 +13,7 @@ def volume_of_torus(major_radius: float, minor_radius: float) -> float: :param major_radius: Distance from the center of the tube to the center of the torus (R) :param minor_radius: Radius of the tube (r) :return: Volume of the torus - + >>> volume_of_torus(3, 1) 59.21762640653615 >>> volume_of_torus(5, 2) @@ -19,8 +21,10 @@ def volume_of_torus(major_radius: float, minor_radius: float) -> float: """ if major_radius < 0 or minor_radius < 0: raise ValueError("Radii must be non-negative") - return 2 * (math.pi ** 2) * major_radius * (minor_radius ** 2) + return 2 * (math.pi**2) * major_radius * (minor_radius**2) + if __name__ == "__main__": import doctest + doctest.testmod() From 64cdce0ab577fa4278fed2e6bb715bd47787963e Mon Sep 17 00:00:00 2001 From: Gopesh Pandey Date: Sat, 17 Jan 2026 02:34:31 +0530 Subject: [PATCH 3/9] Update volume_of_torus.py --- maths/volume_of_torus.py | 1 - 1 file changed, 1 deletion(-) diff --git a/maths/volume_of_torus.py b/maths/volume_of_torus.py index 3f930f977b11..8a1aa9c60fc3 100644 --- a/maths/volume_of_torus.py +++ b/maths/volume_of_torus.py @@ -2,7 +2,6 @@ Volume of a Torus Board: https://en.wikipedia.org/wiki/Torus """ - import math From eec1faf253874a880563f9847aa57507c6278c7e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 16 Jan 2026 21:15:30 +0000 Subject: [PATCH 4/9] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- maths/volume_of_torus.py | 1 + 1 file changed, 1 insertion(+) diff --git a/maths/volume_of_torus.py b/maths/volume_of_torus.py index 8a1aa9c60fc3..3f930f977b11 100644 --- a/maths/volume_of_torus.py +++ b/maths/volume_of_torus.py @@ -2,6 +2,7 @@ Volume of a Torus Board: https://en.wikipedia.org/wiki/Torus """ + import math From 2e2d33a3b12bf1b038c859f1859c9c0dff1fe8a8 Mon Sep 17 00:00:00 2001 From: Gopesh Pandey Date: Sat, 17 Jan 2026 03:15:30 +0530 Subject: [PATCH 5/9] Delete maths/volume_of_torus.py --- maths/volume_of_torus.py | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 maths/volume_of_torus.py diff --git a/maths/volume_of_torus.py b/maths/volume_of_torus.py deleted file mode 100644 index 3f930f977b11..000000000000 --- a/maths/volume_of_torus.py +++ /dev/null @@ -1,30 +0,0 @@ -""" -Volume of a Torus -Board: https://en.wikipedia.org/wiki/Torus -""" - -import math - - -def volume_of_torus(major_radius: float, minor_radius: float) -> float: - """ - Calculate the volume of a torus. - - :param major_radius: Distance from the center of the tube to the center of the torus (R) - :param minor_radius: Radius of the tube (r) - :return: Volume of the torus - - >>> volume_of_torus(3, 1) - 59.21762640653615 - >>> volume_of_torus(5, 2) - 394.7841760435743 - """ - if major_radius < 0 or minor_radius < 0: - raise ValueError("Radii must be non-negative") - return 2 * (math.pi**2) * major_radius * (minor_radius**2) - - -if __name__ == "__main__": - import doctest - - doctest.testmod() From 2a2f2078e63afe883b9f24bb322abb0b00c631e7 Mon Sep 17 00:00:00 2001 From: Gopesh Pandey Date: Sat, 17 Jan 2026 03:17:59 +0530 Subject: [PATCH 6/9] Added volume_of_torus algorithm in maths Implemented the formula for the volume of a torus with type hints and doctests. --- maths/volume_of_torus.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 maths/volume_of_torus.py diff --git a/maths/volume_of_torus.py b/maths/volume_of_torus.py new file mode 100644 index 000000000000..3bb97364692c --- /dev/null +++ b/maths/volume_of_torus.py @@ -0,0 +1,38 @@ +""" +Volume of a Torus +Reference: https://en.wikipedia.org/wiki/Torus +""" + +from math import pi + + +def volume_of_torus(major_radius: float, minor_radius: float) -> float: + """ + Calculate the volume of a torus. + + Formula: + V = 2 * π² * R * r² + + :param major_radius: Distance from the center of the tube to the center of the torus (R) + :param minor_radius: Radius of the tube (r) + :return: Volume of the torus + + >>> volume_of_torus(3.0, 1.0) + 59.21762640653615 + >>> volume_of_torus(5.0, 2.0) + 394.7841760435743 + >>> volume_of_torus(0.0, 0.0) + 0.0 + """ + if major_radius < 0: + raise ValueError("major_radius must be non-negative") + if minor_radius < 0: + raise ValueError("minor_radius must be non-negative") + + return 2 * (pi ** 2) * major_radius * (minor_radius ** 2) + + +if __name__ == "__main__": + import doctest + + doctest.testmod() From acbe730b66cb417bb0448a1c83cc9bce994d43ad Mon Sep 17 00:00:00 2001 From: Gopesh Pandey Date: Sat, 17 Jan 2026 03:22:51 +0530 Subject: [PATCH 7/9] Delete maths/volume_of_torus.py --- maths/volume_of_torus.py | 38 -------------------------------------- 1 file changed, 38 deletions(-) delete mode 100644 maths/volume_of_torus.py diff --git a/maths/volume_of_torus.py b/maths/volume_of_torus.py deleted file mode 100644 index 3bb97364692c..000000000000 --- a/maths/volume_of_torus.py +++ /dev/null @@ -1,38 +0,0 @@ -""" -Volume of a Torus -Reference: https://en.wikipedia.org/wiki/Torus -""" - -from math import pi - - -def volume_of_torus(major_radius: float, minor_radius: float) -> float: - """ - Calculate the volume of a torus. - - Formula: - V = 2 * π² * R * r² - - :param major_radius: Distance from the center of the tube to the center of the torus (R) - :param minor_radius: Radius of the tube (r) - :return: Volume of the torus - - >>> volume_of_torus(3.0, 1.0) - 59.21762640653615 - >>> volume_of_torus(5.0, 2.0) - 394.7841760435743 - >>> volume_of_torus(0.0, 0.0) - 0.0 - """ - if major_radius < 0: - raise ValueError("major_radius must be non-negative") - if minor_radius < 0: - raise ValueError("minor_radius must be non-negative") - - return 2 * (pi ** 2) * major_radius * (minor_radius ** 2) - - -if __name__ == "__main__": - import doctest - - doctest.testmod() From 84f96a7aa6b110be226dcb688479734c25f44147 Mon Sep 17 00:00:00 2001 From: Gopesh Pandey Date: Sat, 17 Jan 2026 03:25:32 +0530 Subject: [PATCH 8/9] Create Volume_of_Torus --- maths/Volume_of_Torus | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 maths/Volume_of_Torus diff --git a/maths/Volume_of_Torus b/maths/Volume_of_Torus new file mode 100644 index 000000000000..3bb97364692c --- /dev/null +++ b/maths/Volume_of_Torus @@ -0,0 +1,38 @@ +""" +Volume of a Torus +Reference: https://en.wikipedia.org/wiki/Torus +""" + +from math import pi + + +def volume_of_torus(major_radius: float, minor_radius: float) -> float: + """ + Calculate the volume of a torus. + + Formula: + V = 2 * π² * R * r² + + :param major_radius: Distance from the center of the tube to the center of the torus (R) + :param minor_radius: Radius of the tube (r) + :return: Volume of the torus + + >>> volume_of_torus(3.0, 1.0) + 59.21762640653615 + >>> volume_of_torus(5.0, 2.0) + 394.7841760435743 + >>> volume_of_torus(0.0, 0.0) + 0.0 + """ + if major_radius < 0: + raise ValueError("major_radius must be non-negative") + if minor_radius < 0: + raise ValueError("minor_radius must be non-negative") + + return 2 * (pi ** 2) * major_radius * (minor_radius ** 2) + + +if __name__ == "__main__": + import doctest + + doctest.testmod() From e0d7bd122cd4e0eb2d9c7264adebeca1af311695 Mon Sep 17 00:00:00 2001 From: Gopesh Pandey Date: Sat, 17 Jan 2026 03:31:17 +0530 Subject: [PATCH 9/9] Rename Volume_of_Torus to volume_of_torus --- maths/{Volume_of_Torus => volume_of_torus} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename maths/{Volume_of_Torus => volume_of_torus} (100%) diff --git a/maths/Volume_of_Torus b/maths/volume_of_torus similarity index 100% rename from maths/Volume_of_Torus rename to maths/volume_of_torus