我正在试着做一个python程序,找出一个直角三角形缺失的角度。它接受不是斜边的两个边的输入,然后计算斜边。去找一个丢失的角。
这就是我们如何在现实生活中做到这一点。
This is an image showing what I am trying to do, I want to find the θ
要做到这一点,我们必须反正弦对角/斜边。
您可以找到有关here方法的信息
我写了这段python代码,但它没有给出正确的答案...
import math
print("Enter The X:",end="")
x = round(float(input()),1)
#The adjusten side
print("Enter The Z:",end="")
z = round(float(input()),1)
#Getting the Opposite side
h = round(math.sqrt((x*x)+(z*z)),1)
# Finding out the Hypotenuse
m = round(z/h,2)
# Opp/H
#Till here the code works perfect giving the right answers but from here I guess I am doing something wrong
a = math.asin(m)
# inverse sine the Opp/H
print("Go to "+ str(a) +" degree")
#Printing the answer
例如,如果我给出的输入为(邻边)X= 4.0,(对侧)Z= 2.8 Here is the solution for this case
'a‘应该是35度,这大约是0.57的反正弦,但它给出了0.6065058552130869度作为答案'a’。
谢谢!
发布于 2021-05-03 16:16:37
这是以弧度表示的正确答案,你必须将弧度换算成度数。这可以通过math.degrees调用来完成
a = math.degrees(math.asin(m))
https://stackoverflow.com/questions/67365553
复制相似问题