File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change 22Volume of a Torus
33Board: https://en.wikipedia.org/wiki/Torus
44"""
5+
56import math
67
8+
79def 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
2427if __name__ == "__main__" :
2528 import doctest
29+
2630 doctest .testmod ()
You can’t perform that action at this time.
0 commit comments