Write a Python program that displays row by row cosine value from 0 degrees to 360 degrees with a step of 15 degree.
Desired output
0 degree = 1.00
15 degree = 0.97
30 degree = 0.87
...
360 degree = 1.00
CODE
import math
for i in range(0, 361, 15): # looping from 0 to 361 in steps of 15
print(i, "degree =", round(math.cos(math.radians(i)), 2))
OUTPUT
0 degree = 1.0
15 degree = 0.97
30 degree = 0.87
45 degree = 0.71
60 degree = 0.5
75 degree = 0.26
90 degree = 0.0
105 degree = -0.26
120 degree = -0.5
135 degree = -0.71
150 degree = -0.87
165 degree = -0.97
180 degree = -1.0
195 degree = -0.97
210 degree = -0.87
225 degree = -0.71
240 degree = -0.5
255 degree = -0.26
270 degree = -0.0
285 degree = 0.26
300 degree = 0.5
315 degree = 0.71
330 degree = 0.87
345 degree = 0.97
360 degree = 1.0
# Hit the thumbs up if you are fine with the answer. Happy Learning!
Get Answers For Free
Most questions answered within 1 hours.