我試圖讓Python中的計算器,但我發現錯用餘弦定律我已經把英寸的Python 3.3側餘弦定律計算器錯誤
這是我
x = float(input("First Side "))
y = float(input("Second Side "))
z = float(input("Angle which isn't opposite First or Second Side "))
print (" ")
print ("Side is: "+str(math.sqrt(((x**2)+(y**2))-(2*x*y*(math.cos(z)*(180/math.pi))))))
這是我的錯誤
Traceback (most recent call last):
File "D:/Users/---------/Python/test calc.py", line 339, in <module>
print ("Side is: "+str(math.sqrt(((x**2)+(y**2))-(2*x*y*(math.cos(z)*(180/math.pi))))))
ValueError: math domain error
你做這個工作了餘弦定律:
a=√(b^2+c^2−2*b*c*cos(α))
在我做了什麼
x=b
y=c
z=α
哦,公平的說,我使用Python 2.7。以防萬一。 – thumbtackthief