I'm making a program that calculates distance moved of an object however when I run the program using 45 as an angle (sin45 and cos45 are equivalent) the output is different for vertical height and horizontal height
import math angle = float(input("Enter Angle of Movement(In Degrees): ")) print("Angle is: ",angle,"°") horizontal_distance = (abs(overall_distance*math.sin(90-angle))) print("Horizontal Distance:",horizontal_distance,"m") vertical_distance = (abs(overall_distance*math.cos(90-angle))) print("Vertical Distance:",vertical_distance,"m") 3 Answers
The input values for sine and cosine are in radians, not degrees.
5The input is in radian units, not degree. Here's the documentation - .
Instead, you should replace sin(90-angle) with sin( - angle).
UPDATE: Just saw your post about converting degree to radian. You can use math.radians(degree)
5For the second question
import math x = math.radians(float(input())) y = math.radians(float(input())) SIN = math.sin(x) COS = math.cos(y) print(x) print(y) print(SIN) print(COS) 45 45 0.7853981633974483 0.7853981633974483 0.7071067811865476 0.7071067811865476