Calculate the Volume of a Hollow Circular Cylinder. >>> vol_hollow_circular_cylinder(1, 2, 3) 28.274333882308138 >>> vol_hollow_circular_cylinder(1.6, 2.6, 3.6) 47.50088092227767 >>> vol_hollow_circular_cylinder(-1, 2, 3) Traceback (most recent call last): ...
(
inner_radius: float, outer_radius: float, height: float
)
| 400 | |
| 401 | |
| 402 | def vol_hollow_circular_cylinder( |
| 403 | inner_radius: float, outer_radius: float, height: float |
| 404 | ) -> float: |
| 405 | """ |
| 406 | Calculate the Volume of a Hollow Circular Cylinder. |
| 407 | |
| 408 | >>> vol_hollow_circular_cylinder(1, 2, 3) |
| 409 | 28.274333882308138 |
| 410 | >>> vol_hollow_circular_cylinder(1.6, 2.6, 3.6) |
| 411 | 47.50088092227767 |
| 412 | >>> vol_hollow_circular_cylinder(-1, 2, 3) |
| 413 | Traceback (most recent call last): |
| 414 | ... |
| 415 | ValueError: vol_hollow_circular_cylinder() only accepts non-negative values |
| 416 | >>> vol_hollow_circular_cylinder(1, -2, 3) |
| 417 | Traceback (most recent call last): |
| 418 | ... |
| 419 | ValueError: vol_hollow_circular_cylinder() only accepts non-negative values |
| 420 | >>> vol_hollow_circular_cylinder(1, 2, -3) |
| 421 | Traceback (most recent call last): |
| 422 | ... |
| 423 | ValueError: vol_hollow_circular_cylinder() only accepts non-negative values |
| 424 | >>> vol_hollow_circular_cylinder(2, 1, 3) |
| 425 | Traceback (most recent call last): |
| 426 | ... |
| 427 | ValueError: outer_radius must be greater than inner_radius |
| 428 | >>> vol_hollow_circular_cylinder(0, 0, 0) |
| 429 | Traceback (most recent call last): |
| 430 | ... |
| 431 | ValueError: outer_radius must be greater than inner_radius |
| 432 | """ |
| 433 | # Volume - (outer_radius squared - inner_radius squared) * pi * height |
| 434 | if inner_radius < 0 or outer_radius < 0 or height < 0: |
| 435 | raise ValueError( |
| 436 | "vol_hollow_circular_cylinder() only accepts non-negative values" |
| 437 | ) |
| 438 | if outer_radius <= inner_radius: |
| 439 | raise ValueError("outer_radius must be greater than inner_radius") |
| 440 | return pi * (pow(outer_radius, 2) - pow(inner_radius, 2)) * height |
| 441 | |
| 442 | |
| 443 | def vol_conical_frustum(height: float, radius_1: float, radius_2: float) -> float: |