The abs()
function returns the absolute value of a number.
Figure 1 shows a mathematical representation of the abs()
function.
num.abs()
# where num is the number whose absolute value is required
The abs()
function does not take any parameter.
The abs()
function returns the absolute value of a number passed in as a parameter.
#positive numberprint "The value of abs(10) : ", (10).abs(), "\n"#zeroprint "The value of abs(0) : ", (0).abs(), "\n"#negative numberprint "The value of abs(-10) : ", (-10).abs(), "\n"