Define a function called signOf that takes a parameter containing an integer value and returns a 1 if the parameter is positive, 0 if the parameter is 0, and -1 if the parameter is negative

Define a function called signOf that takes a parameter containing an integer value and returns a 1 if the parameter is positive, 0 if the parameter is 0, and -1 if the parameter is negative

LANGUAGE:  PYTHON

CHALLENGE:

Define a function called signOf that takes a parameter containing an integer value and returns a 1 if the parameter is positive, 0 if the parameter is 0, and -1 if the parameter is negative

SOLUTION:


def signOf(int):
if int>0:
    return 1
elif int==0:
    return 0
else:
    return -1

Add comment