r""" | Calculate the Volume of a Cone. | Wikipedia reference: https://en.wikipedia.org/wiki/Cone :return: :math:`\frac{1}{3} \cdot area\_of\_base \cdot height` >>> vol_cone(10, 3) 10.0 >>> vol_cone(1, 1) 0.3333333333333333 >>> vol_cone(1.6, 1.6) 0.85333333333333
(area_of_base: float, height: float)
| 203 | |
| 204 | |
| 205 | def vol_cone(area_of_base: float, height: float) -> float: |
| 206 | r""" |
| 207 | | Calculate the Volume of a Cone. |
| 208 | | Wikipedia reference: https://en.wikipedia.org/wiki/Cone |
| 209 | |
| 210 | :return: :math:`\frac{1}{3} \cdot area\_of\_base \cdot height` |
| 211 | |
| 212 | >>> vol_cone(10, 3) |
| 213 | 10.0 |
| 214 | >>> vol_cone(1, 1) |
| 215 | 0.3333333333333333 |
| 216 | >>> vol_cone(1.6, 1.6) |
| 217 | 0.8533333333333335 |
| 218 | >>> vol_cone(0, 0) |
| 219 | 0.0 |
| 220 | >>> vol_cone(-1, 1) |
| 221 | Traceback (most recent call last): |
| 222 | ... |
| 223 | ValueError: vol_cone() only accepts non-negative values |
| 224 | >>> vol_cone(1, -1) |
| 225 | Traceback (most recent call last): |
| 226 | ... |
| 227 | ValueError: vol_cone() only accepts non-negative values |
| 228 | """ |
| 229 | if height < 0 or area_of_base < 0: |
| 230 | raise ValueError("vol_cone() only accepts non-negative values") |
| 231 | return area_of_base * height / 3.0 |
| 232 | |
| 233 | |
| 234 | def vol_right_circ_cone(radius: float, height: float) -> float: |