Calculate the Volume of a Cuboid. :return: multiple of `width`, `length` and `height` >>> vol_cuboid(1, 1, 1) 1.0 >>> vol_cuboid(1, 2, 3) 6.0 >>> vol_cuboid(1.6, 2.6, 3.6) 14.976 >>> vol_cuboid(0, 0, 0) 0.0 >>> vol_cuboid(-1, 2, 3) Traceback (most r
(width: float, height: float, length: float)
| 171 | |
| 172 | |
| 173 | def vol_cuboid(width: float, height: float, length: float) -> float: |
| 174 | """ |
| 175 | Calculate the Volume of a Cuboid. |
| 176 | |
| 177 | :return: multiple of `width`, `length` and `height` |
| 178 | |
| 179 | >>> vol_cuboid(1, 1, 1) |
| 180 | 1.0 |
| 181 | >>> vol_cuboid(1, 2, 3) |
| 182 | 6.0 |
| 183 | >>> vol_cuboid(1.6, 2.6, 3.6) |
| 184 | 14.976 |
| 185 | >>> vol_cuboid(0, 0, 0) |
| 186 | 0.0 |
| 187 | >>> vol_cuboid(-1, 2, 3) |
| 188 | Traceback (most recent call last): |
| 189 | ... |
| 190 | ValueError: vol_cuboid() only accepts non-negative values |
| 191 | >>> vol_cuboid(1, -2, 3) |
| 192 | Traceback (most recent call last): |
| 193 | ... |
| 194 | ValueError: vol_cuboid() only accepts non-negative values |
| 195 | >>> vol_cuboid(1, 2, -3) |
| 196 | Traceback (most recent call last): |
| 197 | ... |
| 198 | ValueError: vol_cuboid() only accepts non-negative values |
| 199 | """ |
| 200 | if width < 0 or height < 0 or length < 0: |
| 201 | raise ValueError("vol_cuboid() only accepts non-negative values") |
| 202 | return float(width * height * length) |
| 203 | |
| 204 | |
| 205 | def vol_cone(area_of_base: float, height: float) -> float: |