结果错误 [英] Wrong asin result
本文介绍了结果错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的代码:
import math
x = input()
print(math.asin(math.radians(float(x))))
我的x是0.7071067811865475,结果是0到1之间的某个无理数.但是据我所知,它应该在45左右.
My x was 0.7071067811865475, and the result was some irracional number between 0 and 1, but in my knowledge it should have been around 45
推荐答案
您使用错误的函数转换了错误的数字.
You're converting the wrong number with the wrong function.
>>> import math
>>> x = 0.7071067811865475
>>> math.degrees(math.asin(x))
44.99999999999999
>>>
也就是说,给定 x
(角度的正弦)调用 学位
可以将该角度转换为学位.
That is, given x
(which is the sine of an angle) call asin
to compute the angle (in radians), and then use degrees
to convert that angle to degrees.
这篇关于结果错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文