You can download this code by clicking the button below.
This code is now available for download.
Calculate the absolute value of a number, returning the negation if the number is negative, and the number itself if it is non-negative or zero.
Technology Stack : abs() function
Code Type : Function
Code Difficulty :
def abs_value(num):
if num < 0:
return -num
else:
return num