gpt4 book ai didi

python - python中三角函数的计算

转载 作者:太空宇宙 更新时间:2023-11-04 07:18:43 29 4
gpt4 key购买 nike

Python是如何计算三角函数的?我尝试使用

x = ((0.1-0.001)/2)*math.sin(((1/20)*math.pi*20)+(0.5*math.pi*1))+((0.1-0.001)/2)+0.001

我得到了

x = 0.1

这是为什么呢?在通常的计算器(弧度)中,我得到 0.001

最佳答案

在Python 2中,/是整数除法,需要导入__future__ .division对于 float 除法:

>>> from __future__ import division
>>> import math
>>> x = ((0.1-0.001)/2)*math.sin(((1/20)*math.pi*20)+(0.5*math.pi*1))+((0.1-0.001)/2)+0.001
>>> x
0.001

关于python - python中三角函数的计算,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29131918/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com