Positive, Negative, or Zero

Easy ⏱ 8 min 83% acceptance ★★★★★ 4.5
Write a function sign_of(n) that returns "Positive" if n is greater than zero, "Negative" if less than zero, and "Zero" if it equals zero. A classic three-way if/elif/else branch.

Examples

Example 1
Input
sign_of(-5)
Output
"Negative"
Explanation

-5 is less than 0.

Example 2
Input
sign_of(0)
Output
"Zero"
Explanation

0 is neither positive nor negative.

Constraints

  • n is any integer or float.

Topics

Conditional Statementsif/elif/else

Companies

GoogleWipro

Hints

Hint 1

Check for zero first or last — order matters for readability, not correctness here.

Hint 2

Use if / elif / else, not three separate ifs.

Loading the Python runtime… Run executes your code and shows printed output; Submit checks your function against this problem's examples.