Check that the arguments are valid
(init_velocity: float, angle: float)
| 25 | |
| 26 | |
| 27 | def check_args(init_velocity: float, angle: float) -> None: |
| 28 | """ |
| 29 | Check that the arguments are valid |
| 30 | """ |
| 31 | |
| 32 | # Ensure valid instance |
| 33 | if not isinstance(init_velocity, (int, float)): |
| 34 | raise TypeError("Invalid velocity. Should be an integer or float.") |
| 35 | |
| 36 | if not isinstance(angle, (int, float)): |
| 37 | raise TypeError("Invalid angle. Should be an integer or float.") |
| 38 | |
| 39 | # Ensure valid angle |
| 40 | if angle > 90 or angle < 1: |
| 41 | raise ValueError("Invalid angle. Range is 1-90 degrees.") |
| 42 | |
| 43 | # Ensure valid velocity |
| 44 | if init_velocity < 0: |
| 45 | raise ValueError("Invalid velocity. Should be a positive number.") |
| 46 | |
| 47 | |
| 48 | def horizontal_distance(init_velocity: float, angle: float) -> float: |
no outgoing calls
no test coverage detected