我正在寻找一种在python 2或3中执行加/减运算的方法.我不知道该命令或运算符,也找不到执行该操作的命令或运算符.
I am looking for a way to do a plus/minus operation in python 2 or 3. I do not know the command or operator, and I cannot find a command or operator to do this.
我想念什么吗?
推荐答案另一种可能性:不确定性是一个模块用于进行误差容限的计算,即
Another possibility: uncertainties is a module for doing calculations with error tolerances, ie
(2.1 +/- 0.05) + (0.6 +/- 0.05) # => (2.7 +/- 0.1)将被写为
from uncertainties import ufloat ufloat(2.1, 0.05) + ufloat(0.6, 0.05)我得到了一些奇怪的结果,并且在对此进行了更多研究之后,我找出了原因:指定的误差不是公差(如工程蓝图中的硬加性极限),而是一个标准偏差值-这就是上述计算结果的原因
I was getting some odd results, and after a bit more playing with this I figured out why: the specified error is not a tolerance (hard additive limits as in engineering blueprints) but a standard-deviation value - which is why the above calculation results in
ufloat(2.7, 0.07071) # not 0.1 as I expected!更多推荐
python的正/负运算符±
发布评论