abs() function code example
Example 1: abs() absolute
# random integer
integer = -20
print('Absolute value of -20 is:', abs(integer))
#random floating number
floating = -30.33
print('Absolute value of -30.33 is:', abs(floating))
Results
Absolute value of -20 is: 20
Absolute value of -30.33 is: 30.33
Example 2: abs() absolute
# random integer
integer = -20
print('Absolute value of -20 is:', abs(integer))
#random floating number
floating = -30.33
print('Absolute value of -30.33 is:', abs(floating))