a = -2.5427 must be
a = 2.5427 You want to reverse the sign.
Everywhere it is done like this:
a = -a >>> a = -2.5427 >>> a -2.5427 >>> a = abs(a) >>> a 2.5427 Obviously, this is done by changing the sign: You can either assign the opposite sign to the number a=-a , a=a*(-1) , or take this number by the absolute value . Keep in mind that the numbers in the Python language are immutable , and therefore it is better, changing the sign, to assign the number to another variable - b=-a or b=abs(a) or b=a*(-1)
a *= -1 # То же самое как а = a * -1 Source: https://ru.stackoverflow.com/questions/936994/
All Articles