signum function https en wikipedia orgwikisignfunction applies signum function on the number custom test cases signum10 1 signum10 1 signum0 0 signum20 5 1 signum20 5 1 signum1e6 1 signum1e6 1 signumhello traceback most recent call last typeerror not supported between instances of str and int signum traceback most recent call last typeerror not supported between instances of list and int tests the signum function testsignum applies signum function on the number custom test cases signum 10 1 signum 10 1 signum 0 0 signum 20 5 1 signum 20 5 1 signum 1e 6 1 signum 1e 6 1 signum hello traceback most recent call last typeerror not supported between instances of str and int signum traceback most recent call last typeerror not supported between instances of list and int tests the signum function test_signum
def signum(num: float) -> int:
    
    if num < 0:
        return -1
    return 1 if num else 0


def test_signum() -> None:
    
    assert signum(5) == 1
    assert signum(-5) == -1
    assert signum(0) == 0
    assert signum(10.5) == 1
    assert signum(-10.5) == -1
    assert signum(1e-6) == 1
    assert signum(-1e-6) == -1
    assert signum(123456789) == 1
    assert signum(-123456789) == -1


if __name__ == "__main__":
    print(signum(12))
    print(signum(-12))
    print(signum(0))