17
17
"""
18
18
19
19
# Importing packages
20
- from math import radians as angle_to_radians
20
+ from math import radians as deg_to_rad
21
21
from math import sin
22
22
23
23
# Acceleration Constant on Earth (unit m/s^2)
@@ -31,10 +31,10 @@ def check_args(init_velocity: float, angle: float) -> None:
31
31
32
32
# Ensure valid instance
33
33
if not isinstance (init_velocity , (int , float )):
34
- raise TypeError ("Invalid velocity. Should be a positive number ." )
34
+ raise TypeError ("Invalid velocity. Should be an integer or float ." )
35
35
36
36
if not isinstance (angle , (int , float )):
37
- raise TypeError ("Invalid angle. Range is 1-90 degrees ." )
37
+ raise TypeError ("Invalid angle. Should be an integer or float ." )
38
38
39
39
# Ensure valid angle
40
40
if angle > 90 or angle < 1 :
@@ -71,7 +71,7 @@ def horizontal_distance(init_velocity: float, angle: float) -> float:
71
71
ValueError: Invalid angle. Range is 1-90 degrees.
72
72
"""
73
73
check_args (init_velocity , angle )
74
- radians = angle_to_radians (2 * angle )
74
+ radians = deg_to_rad (2 * angle )
75
75
return round (init_velocity ** 2 * sin (radians ) / g , 2 )
76
76
77
77
@@ -94,14 +94,14 @@ def max_height(init_velocity: float, angle: float) -> float:
94
94
>>> max_height("a", 20)
95
95
Traceback (most recent call last):
96
96
...
97
- TypeError: Invalid velocity. Should be a positive number .
97
+ TypeError: Invalid velocity. Should be an integer or float .
98
98
>>> horizontal_distance(30, "b")
99
99
Traceback (most recent call last):
100
100
...
101
- TypeError: Invalid angle. Range is 1-90 degrees .
101
+ TypeError: Invalid angle. Should be an integer or float .
102
102
"""
103
103
check_args (init_velocity , angle )
104
- radians = angle_to_radians (angle )
104
+ radians = deg_to_rad (angle )
105
105
return round (init_velocity ** 2 * sin (radians ) ** 2 / (2 * g ), 2 )
106
106
107
107
@@ -128,10 +128,10 @@ def total_time(init_velocity: float, angle: float) -> float:
128
128
>>> total_time(30, "b")
129
129
Traceback (most recent call last):
130
130
...
131
- TypeError: Invalid angle. Range is 1-90 degrees .
131
+ TypeError: Invalid angle. Should be an integer or float .
132
132
"""
133
133
check_args (init_velocity , angle )
134
- radians = angle_to_radians (angle )
134
+ radians = deg_to_rad (angle )
135
135
return round (2 * init_velocity * sin (radians ) / g , 2 )
136
136
137
137
0 commit comments