Home>

I am practicing the output of trigonometric functions in Python, but the answer is returned as a negative value.
What is the cause of this?

import math
def ex3_7 (deg):
    rad = 2 * math.pi * deg/360
    return (rad)
def ex3_8_sin (deg):
    rad_sin = math.sin (deg)
    return (rad_sin)
def ex3_8_cos (deg):
    rad_cos = math.cos (deg)
    return (rad_cos)
print (ex3_8_sin (60))
print (ex3_8_cos (60))
  • The output result is as follows
    -0.3048106211022167
    -0.9524129804151563

Postscript
Make something that calculates ex3_8_sin and ex3_8_cos when the angle θ is given using ex3_7.

  • Answer # 1

    Since the sin function and cos function of math pass radians as arguments
    When calculating from angles, degrees need to be converted to radians.
    The function for that conversion is the ex3_7 () function.

    Therefore

    print (ex3_8_sin (ex3_7 (60)))
    print (ex3_8_cos (ex3_7 (60)))

    Isn't it okay?

  • Answer # 2

    It's about math.

    When 180 ° When 90 °

    Therefore, it is normal for the output to be negative.

Trends