plus/minus operator for python ±

前端 未结 7 593
遇见更好的自我
遇见更好的自我 2020-12-31 02:20

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.

Am I

7条回答
  •  离开以前
    2020-12-31 03:03

    Instead of computing expressions like

    s1 = sqrt((125.0 + 10.0*sqrt(19)) / 366.0)
    s2 = sqrt((125.0 - 10.0*sqrt(19)) / 366.0)
    

    you could use

    pm = numpy.array([+1, -1])
    s1, s2 = sqrt((125.0 + pm * 10.0*sqrt(19)) / 366.0)
    

提交回复
热议问题