Absolute Value Function

  • Share this:

Code introduction


Returns the absolute value of a given number. If the number is negative, it returns its opposite; otherwise, it returns the number itself.


Technology Stack : Built-in function

Code Type : Function

Code Difficulty :


                
                    
def abs_value(num):
    if num < 0:
        return -num
    return num