Back to Practice Dashboard
Python BasicsEasy

Positive or Negative number

Learn how to solve the 'Positive or Negative number' problem. This detailed resource details brute force and optimized approaches.

Problem Statement

Easy

Write a function check_sign(n) that takes an integer n and returns the string "Positive" if n is greater than zero, "Negative" if n is less than zero, or "Zero" if n is exactly zero.

Constraints
  • -10^9 <= n <= 10^9

Examples

Example 1
Input
n = 5
Output
"Positive"
Explanation

5 is greater than 0, so we return "Positive".

Example 2
Input
n = -3
Output
"Negative"
Explanation

-3 is less than 0, so we return "Negative".

Example 3
Input
n = 0
Output
"Zero"
Explanation

0 is neither positive nor negative, so we return "Zero".

Need a Hint?
Use simple arithmetic operators (like modulo `%`, division `//`), conditional checks, or loops to inspect number properties.
Edge Cases to Watch
  • Empty list or null input variables
  • Single item lists/arrays
  • Extremely large input bounds causing integer or stack overflow

Ready to Solve?

Open the problem in PyRun's browser-based Python editor. Your code runs fully offline — no server required.

Open in Editor