Absolute Value Calculation

  • Share this:

Code introduction


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                
              
Tags: