我不知道如何让Python在执行重复正弦运算时像我的计算器一样工作。
我的Python代码:
number = float(.565)
pi = float(math.pi)
for j in range(25):
number = round(math.sin(number*pi), 16)
这将返回0.446445551265。
当我用我的计算器做同样的运算时,我得到0.4464454868。
无论我对round()使用多高的精度,我都不能得到与我的计算器相同的结果。
我也尝试过使用Decimal库,但没有得到更好的结果。有什么想法吗?
我在我的卡西欧计算器上做了一点python,我遇到了一个小问题,我的计算器使用的python版本是microPython 1.9.4。我无法使用import time,因为这个版本中没有time模块。任何帮助都将不胜感激。
编辑:将版本更改为1.9.4
我的代码( time.sleep()在底部附近):
import time
barriers = []
playerPosition = [11, 1]
playTime = 0
while playTime <= 0:
line = 6
while line >= 1:
if line > 2:
我用Python 3.3.2制作了毕达哥拉斯定理计算器。
我在几行线上做了打印,这样我就可以做一个图表:
print("Welcome to the Pythagoras Theorem Calculator, powered by Python!")
print("Below are the values a, b and c. You will need to input these values after.")
print('''
| .
| .
| .
side a|