You can download this code by clicking the button below.
This code is now available for download.
Calculates and returns the absolute value of a number. If the input number is negative, it returns its opposite; if the input number is non-negative, it returns itself.
Technology Stack : Python built-in types and comparison operators
Code Type : Function
Code Difficulty :
def abs_value(number):
if number < 0:
return -number
else:
return number