首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >使用python中的反正弦/反正弦(math.asin)函数查找直角三角形的缺角

使用python中的反正弦/反正弦(math.asin)函数查找直角三角形的缺角
EN

Stack Overflow用户
提问于 2021-05-03 16:12:30
回答 1查看 85关注 0票数 1

我正在试着做一个python程序,找出一个直角三角形缺失的角度。它接受不是斜边的两个边的输入,然后计算斜边。去找一个丢失的角。

这就是我们如何在现实生活中做到这一点。

This is an image showing what I am trying to do, I want to find the θ

要做到这一点,我们必须反正弦对角/斜边。

您可以找到有关here方法的信息

我写了这段python代码,但它没有给出正确的答案...

代码语言:javascript
运行
复制
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’。

谢谢!

EN

回答 1

Stack Overflow用户

发布于 2021-05-03 16:16:37

这是以弧度表示的正确答案,你必须将弧度换算成度数。这可以通过math.degrees调用来完成

代码语言:javascript
运行
复制
a = math.degrees(math.asin(m))
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67365553

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档