Python数学模块显示了完全错误的结果?

2024-04-26 06:29:24 发布

您现在位置:Python中文网/ 问答频道 /正文

我不知道我做错了什么。你知道吗

from math import *
# triangle Law of Sines test:
a = float(3)
b = float(3)
c = 4.24264

A = float(45)
B = float(45)
C = float(90)

# it should be equal to the diameter of the triangle's 
# ...circumcircle when convert radians to degrees (2.12132) :
print a /sin(A)
print c /sin(C)

# and just test angles :
print degrees( sin( float(45) ) ) # 'SHOULD BE 2.8284'
print degrees( sin( float(90) ) ) # 'SHOULD BE 1'

…以及打印输出:

>> 3.52566408941
>> 4.74570003753
>> 48.7531807286
>> 51.2222357231

Tags: ofthetofromtestimportmathsin
1条回答
网友
1楼 · 发布于 2024-04-26 06:29:24

您应该执行以下操作:

sin( radians(90) ) 

^{}将给定的角度从度转换为弧度,并且由于sin期望radians,现在它应该像您期望的那样打印1。你知道吗

相关问题 更多 >