r""" | Calculate the Volume of a Prism. | Wikipedia reference: https://en.wikipedia.org/wiki/Prism_(geometry) :return: :math:`V = B \cdot h` >>> vol_prism(10, 2) 20.0 >>> vol_prism(11, 1) 11.0 >>> vol_prism(1.6, 1.6) 2.5600000000000005 >>> vol_prism(0, 0)
(area_of_base: float, height: float)
| 259 | |
| 260 | |
| 261 | def vol_prism(area_of_base: float, height: float) -> float: |
| 262 | r""" |
| 263 | | Calculate the Volume of a Prism. |
| 264 | | Wikipedia reference: https://en.wikipedia.org/wiki/Prism_(geometry) |
| 265 | |
| 266 | :return: :math:`V = B \cdot h` |
| 267 | |
| 268 | >>> vol_prism(10, 2) |
| 269 | 20.0 |
| 270 | >>> vol_prism(11, 1) |
| 271 | 11.0 |
| 272 | >>> vol_prism(1.6, 1.6) |
| 273 | 2.5600000000000005 |
| 274 | >>> vol_prism(0, 0) |
| 275 | 0.0 |
| 276 | >>> vol_prism(-1, 1) |
| 277 | Traceback (most recent call last): |
| 278 | ... |
| 279 | ValueError: vol_prism() only accepts non-negative values |
| 280 | >>> vol_prism(1, -1) |
| 281 | Traceback (most recent call last): |
| 282 | ... |
| 283 | ValueError: vol_prism() only accepts non-negative values |
| 284 | """ |
| 285 | if height < 0 or area_of_base < 0: |
| 286 | raise ValueError("vol_prism() only accepts non-negative values") |
| 287 | return float(area_of_base * height) |
| 288 | |
| 289 | |
| 290 | def vol_pyramid(area_of_base: float, height: float) -> float: |