# Mastery test 1 - part 3

def add_nums(numlist):
    """
    >>> add_nums([2, 7, 9, 10, 13, 1, 5, 12])
    59
    >>> add_nums([3, 7, 2.5, -4])
    8.5
    """
    return sum(numlist)


def compare(a, b):
    """
    >>> compare(3, 1)
    '3 is greater than 1'
    >>> compare(2, 5)
    '2 is less than 5'
    >>> compare(4, 4)
    '4 and 4 are equal'
    """
    if a > b:
        return str(a) + ' is greater than ' + str(b)
    elif a < b:
        return str(a) + ' is less than ' + str(b)
    else:
        return str(a) + ' and ' + str(b) + ' are equal'


def hypotenuse(a, b):
    """
    Get the hypotenuse (longest side) of a right angled triangle with
    other sides of length a and b.  It is the square root of a squared
    plus b squared.
    >>> hypotenuse(3, 4)
    5.0
    >>> hypotenuse(7, 5)
    8.6023252670426267
    """
    import math
    return math.hypot(a,b)
    # or return (a**2 + b**2) ** 0.5

    
def sortstuff(mylist):
    """
    >>> sortstuff([3, 5, 1, 9, 13, 2])
    [1, 2, 3, 5, 9, 13]
    >>> sortstuff(["one", "two", "three", "four"])
    ['four', 'one', 'three', 'two']
    """
    mylist.sort()
    return mylist


def sortstuff_reverse(mylist):
    """
    >>> sortstuff_reverse([3, 5, 1, 9, 13, 2])
    [13, 9, 5, 3, 2, 1]
    >>> sortstuff_reverse(["one", "two", "three", "four"])
    ['two', 'three', 'one', 'four']
    """
    mylist.sort()
    mylist.reverse()
    return mylist


if __name__ == '__main__':
    import doctest
    doctest.testmod(verbose=True)
