Skip to content

Commit ac278a5

Browse files
authored
Update horizontal_projectile_motion.py
This commit is about logic of this program. Changes made aim to allow a good understanding of what is done.
1 parent 47a44ab commit ac278a5

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

physics/horizontal_projectile_motion.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"""
1818

1919
# Importing packages
20-
from math import radians as angle_to_radians
20+
from math import radians as deg_to_rad
2121
from math import sin
2222

2323
# Acceleration Constant on Earth (unit m/s^2)
@@ -31,10 +31,10 @@ def check_args(init_velocity: float, angle: float) -> None:
3131

3232
# Ensure valid instance
3333
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.")
3535

3636
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.")
3838

3939
# Ensure valid angle
4040
if angle > 90 or angle < 1:
@@ -71,7 +71,7 @@ def horizontal_distance(init_velocity: float, angle: float) -> float:
7171
ValueError: Invalid angle. Range is 1-90 degrees.
7272
"""
7373
check_args(init_velocity, angle)
74-
radians = angle_to_radians(2 * angle)
74+
radians = deg_to_rad(2 * angle)
7575
return round(init_velocity**2 * sin(radians) / g, 2)
7676

7777

@@ -101,7 +101,7 @@ def max_height(init_velocity: float, angle: float) -> float:
101101
TypeError: Invalid angle. Range is 1-90 degrees.
102102
"""
103103
check_args(init_velocity, angle)
104-
radians = angle_to_radians(angle)
104+
radians = deg_to_rad(angle)
105105
return round(init_velocity**2 * sin(radians) ** 2 / (2 * g), 2)
106106

107107

@@ -131,7 +131,7 @@ def total_time(init_velocity: float, angle: float) -> float:
131131
TypeError: Invalid angle. Range is 1-90 degrees.
132132
"""
133133
check_args(init_velocity, angle)
134-
radians = angle_to_radians(angle)
134+
radians = deg_to_rad(angle)
135135
return round(2 * init_velocity * sin(radians) / g, 2)
136136

137137

0 commit comments

Comments
 (0)