Learning Scientific Programming with Python (2nd edition)

P2.2.3: The sign function

Question P2.2.3

Some languages provide a sign(a) function which returns -1 if its argument, a, is negative and 1 otherwise. Python does not provide such a function, but the math module does include a function math.copysign(x, y) which returns the absolute value of x with the sign of y. How would you use this function in the same way as the missing sign(a) function?