Calculates the volume of a regular dodecahedron v = ((15 + (7 * (5** (1 / 2)))) / 4) * (e**3) where: v --> is the volume of the dodecahedron e --> is the length of the edge reference-->"Dodecahedron" Study.com <https://study.com/academy/lesson/dodecahedron-volume-surface
(edge: float)
| 38 | |
| 39 | |
| 40 | def dodecahedron_volume(edge: float) -> float: |
| 41 | """ |
| 42 | Calculates the volume of a regular dodecahedron |
| 43 | v = ((15 + (7 * (5** (1 / 2)))) / 4) * (e**3) |
| 44 | where: |
| 45 | v --> is the volume of the dodecahedron |
| 46 | e --> is the length of the edge |
| 47 | reference-->"Dodecahedron" Study.com |
| 48 | <https://study.com/academy/lesson/dodecahedron-volume-surface-area-formulas.html> |
| 49 | |
| 50 | :param edge: length of the edge of the dodecahedron |
| 51 | :type edge: float |
| 52 | :return: the volume of the dodecahedron as a float |
| 53 | |
| 54 | Tests: |
| 55 | >>> dodecahedron_volume(5) |
| 56 | 957.8898700780791 |
| 57 | >>> dodecahedron_volume(10) |
| 58 | 7663.118960624633 |
| 59 | >>> dodecahedron_volume(-1) |
| 60 | Traceback (most recent call last): |
| 61 | ... |
| 62 | ValueError: Length must be a positive. |
| 63 | """ |
| 64 | |
| 65 | if edge <= 0 or not isinstance(edge, int): |
| 66 | raise ValueError("Length must be a positive.") |
| 67 | return ((15 + (7 * (5 ** (1 / 2)))) / 4) * (edge**3) |
| 68 | |
| 69 | |
| 70 | if __name__ == "__main__": |
nothing calls this directly
no outgoing calls
no test coverage detected