Calculate the Surface Area of a Hemisphere. Formula: 3 * pi * r^2 >>> surface_area_hemisphere(5) 235.61944901923448 >>> surface_area_hemisphere(1) 9.42477796076938 >>> surface_area_hemisphere(0) 0.0 >>> surface_area_hemisphere(1.1) 11.403981332530
(radius: float)
| 81 | |
| 82 | |
| 83 | def surface_area_hemisphere(radius: float) -> float: |
| 84 | """ |
| 85 | Calculate the Surface Area of a Hemisphere. |
| 86 | Formula: 3 * pi * r^2 |
| 87 | |
| 88 | >>> surface_area_hemisphere(5) |
| 89 | 235.61944901923448 |
| 90 | >>> surface_area_hemisphere(1) |
| 91 | 9.42477796076938 |
| 92 | >>> surface_area_hemisphere(0) |
| 93 | 0.0 |
| 94 | >>> surface_area_hemisphere(1.1) |
| 95 | 11.40398133253095 |
| 96 | >>> surface_area_hemisphere(-1) |
| 97 | Traceback (most recent call last): |
| 98 | ... |
| 99 | ValueError: surface_area_hemisphere() only accepts non-negative values |
| 100 | """ |
| 101 | if radius < 0: |
| 102 | raise ValueError("surface_area_hemisphere() only accepts non-negative values") |
| 103 | return 3 * pi * radius**2 |
| 104 | |
| 105 | |
| 106 | def surface_area_cone(radius: float, height: float) -> float: |