math.cos(x) not returning correct value?

后端 未结 3 781
一向
一向 2021-01-25 22:45

I just started using python, and am having difficulty with a very basic program. I want to calculate the cosine of -20 degrees. It is my understanding that the default value is

3条回答
  •  佛祖请我去吃肉
    2021-01-25 23:13

    You need to input in radians, so do

    math.cos(math.radians(-20))
    

    math.radians(-20) converts -20 degrees to radians.

提交回复
热议问题