首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >python中sin(45)和cos(45)的值不同,尽管它们是等效的

python中sin(45)和cos(45)的值不同,尽管它们是等效的
EN

Stack Overflow用户
提问于 2020-11-02 02:51:52
回答 3查看 543关注 0票数 0

我正在编写一个计算物体移动距离的程序,但是当我运行该程序时,使用45作为角度(sin45和cos45是等效的),输出的垂直高度和水平高度不同

代码语言:javascript
运行
复制
import math

angle = float(input("Enter Angle of Movement(In Degrees): "))
print("Angle is: ",angle,"°")

horizontal_distance = (abs(overall_distance*math.sin(90-angle)))
print("Horizontal Distance:",horizontal_distance,"m")

vertical_distance = (abs(overall_distance*math.cos(90-angle)))
print("Vertical Distance:",vertical_distance,"m")
EN

Stack Overflow用户

发布于 2020-11-02 03:05:54

对于第二个问题

代码语言:javascript
运行
复制
import math
x = math.radians(float(input()))
y = math.radians(float(input()))
SIN = math.sin(x)
COS = math.cos(y)
print(x)
print(y)
print(SIN)
print(COS)


45 
45
0.7853981633974483
0.7853981633974483
0.7071067811865476
0.7071067811865476
票数 0
EN
查看全部 3 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64635695

复制
相关文章

相似问题

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