FunctionRacerProblemsRace

Sign of Each

BeginnerNumPyPython

Return an array the same length as nums where every item is 1 if the number is positive, -1 if it is negative and 0 if it is zero. Hint: np.sign.

Example 1

nums [8,-3,0,12]
returns [1,-1,0,1]

The signs are 1, -1, 0, 1.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More NumPy problems