>>> period_of_pendulum(1.23) 2.2252155506257845 >>> period_of_pendulum(2.37) 3.0888278441908574 >>> period_of_pendulum(5.63) 4.76073193364765 >>> period_of_pendulum(-12) Traceback (most recent call last): ... ValueError: The length should be non-negative
(length: float)
| 28 | |
| 29 | |
| 30 | def period_of_pendulum(length: float) -> float: |
| 31 | """ |
| 32 | >>> period_of_pendulum(1.23) |
| 33 | 2.2252155506257845 |
| 34 | >>> period_of_pendulum(2.37) |
| 35 | 3.0888278441908574 |
| 36 | >>> period_of_pendulum(5.63) |
| 37 | 4.76073193364765 |
| 38 | >>> period_of_pendulum(-12) |
| 39 | Traceback (most recent call last): |
| 40 | ... |
| 41 | ValueError: The length should be non-negative |
| 42 | >>> period_of_pendulum(0) |
| 43 | 0.0 |
| 44 | """ |
| 45 | if length < 0: |
| 46 | raise ValueError("The length should be non-negative") |
| 47 | return 2 * pi * (length / g) ** 0.5 |
| 48 | |
| 49 | |
| 50 | if __name__ == "__main__": |
nothing calls this directly
no outgoing calls
no test coverage detected