r""" | Calculate the volume of a hemisphere | Wikipedia reference: https://en.wikipedia.org/wiki/Hemisphere | Other references: https://www.cuemath.com/geometry/hemisphere :return: :math:`\frac{2}{3} \cdot \pi \cdot radius^3` >>> vol_hemisphere(1) 2.0943951023931953 >>>
(radius: float)
| 343 | |
| 344 | |
| 345 | def vol_hemisphere(radius: float) -> float: |
| 346 | r""" |
| 347 | | Calculate the volume of a hemisphere |
| 348 | | Wikipedia reference: https://en.wikipedia.org/wiki/Hemisphere |
| 349 | | Other references: https://www.cuemath.com/geometry/hemisphere |
| 350 | |
| 351 | :return: :math:`\frac{2}{3} \cdot \pi \cdot radius^3` |
| 352 | |
| 353 | >>> vol_hemisphere(1) |
| 354 | 2.0943951023931953 |
| 355 | >>> vol_hemisphere(7) |
| 356 | 718.377520120866 |
| 357 | >>> vol_hemisphere(1.6) |
| 358 | 8.57864233940253 |
| 359 | >>> vol_hemisphere(0) |
| 360 | 0.0 |
| 361 | >>> vol_hemisphere(-1) |
| 362 | Traceback (most recent call last): |
| 363 | ... |
| 364 | ValueError: vol_hemisphere() only accepts non-negative values |
| 365 | """ |
| 366 | if radius < 0: |
| 367 | raise ValueError("vol_hemisphere() only accepts non-negative values") |
| 368 | # Volume is radius cubed * pi * 2/3 |
| 369 | return pow(radius, 3) * pi * 2 / 3 |
| 370 | |
| 371 | |
| 372 | def vol_circular_cylinder(radius: float, height: float) -> float: |