Problem No 2
Determine Positive, Negative, or Zero
Easy≈ 8 minute session
Lesson guide
What this Python exercise practices
Determine Positive, Negative, or Zero is a beginner practice lesson that focuses on functions, parameters, return values. It is designed to be solved in about 8 minutes with examples, starter code, and test feedback.
Prerequisites
- Python variables
- Function parameters
- Return values
Difficulty and time
- Level
- Beginner
- Estimated time
- 8 minutes
Summary
Classify a number as positive, negative, or zero using conditional branches.
Problem statement
Write a function sign_of_number(n) that inspects the number n and returns: - 'Positive' if n > 0 - 'Negative' if n < 0 - 'Zero' if n == 0 Use if-elif-else branching to implement the logic.
Task
Implement a function that returns 'Positive', 'Negative', or 'Zero' based on the sign of a number.
Examples
Example 1
Input
n = -5
Output
Negative
Explanation
-5 is less than zero.
Input format
A single integer n.
Output format
A string: 'Positive', 'Negative', or 'Zero'.
Constraints
n fits in standard integer range; can be negative, zero, or positive.
Samples
Sample input 0
5
Sample output 0
Positive
Explanation 0
5 is greater than zero.
AI assistant
Ask me anything!
Need help? I can explain the core idea behind this problem, review your current code, and give targeted hints. Use “Teach Theory” for the concept, “Get AI hint” for a quick scaffold nudge, or ask a specific question below.
Chat history is temporary and will not be saved.
Free preview includes 1 Teach Theory response and 1 AI hint per unlocked preview lesson.