Skip to content

Commit cda24f7

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 098a1b2 commit cda24f7

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

maths/volume_of_torus.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,29 @@
22
Volume of a Torus
33
Board: https://en.wikipedia.org/wiki/Torus
44
"""
5+
56
import math
67

8+
79
def volume_of_torus(major_radius: float, minor_radius: float) -> float:
810
"""
911
Calculate the volume of a torus.
1012
1113
:param major_radius: Distance from the center of the tube to the center of the torus (R)
1214
:param minor_radius: Radius of the tube (r)
1315
:return: Volume of the torus
14-
16+
1517
>>> volume_of_torus(3, 1)
1618
59.21762640653615
1719
>>> volume_of_torus(5, 2)
1820
394.7841760435743
1921
"""
2022
if major_radius < 0 or minor_radius < 0:
2123
raise ValueError("Radii must be non-negative")
22-
return 2 * (math.pi ** 2) * major_radius * (minor_radius ** 2)
24+
return 2 * (math.pi**2) * major_radius * (minor_radius**2)
25+
2326

2427
if __name__ == "__main__":
2528
import doctest
29+
2630
doctest.testmod()

0 commit comments

Comments
 (0)