python的正/负运算符±

编程入门 行业动态 更新时间:2024-10-27 10:29:13
本文介绍了python的正/负运算符±的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在寻找一种在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的正/负运算符±

本文发布于:2023-11-22 09:09:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1616819.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:运算符   python

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!