MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / check_args

Function check_args

physics/horizontal_projectile_motion.py:27–45  ·  view source on GitHub ↗

Check that the arguments are valid

(init_velocity: float, angle: float)

Source from the content-addressed store, hash-verified

25
26
27def 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
48def horizontal_distance(init_velocity: float, angle: float) -> float:

Callers 3

horizontal_distanceFunction · 0.85
max_heightFunction · 0.85
total_timeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected