0
What does "math.abs" do?
3 Respostas
+ 5
If you're still unsure:
In mathematics, the absolute value of a number is defined as:
|x| =
if x < 0: (-1)*x
if x >= 0: x
So, if the number is negative multiply it by -1. Otherwise, leave it as is.
+ 3
And going deeper, absolute value of a number is a distance from zero to that number. So it's always positive.
+ 2
Returns absolute value of a number. abs(5)=5; abs(-5)=5