Python: Check if a number is positive, negative or zero
Python Basic: Exercise-109 with Solution
Write a Python program to check if a number is positive, negative or zero.
num = float(input("Input a number: ")) if num > 0: print("It is positive number") elif num == 0: print("It is Zero") else: print("It is a negative number")
Input a number: 150 It is positive number
Visualize Python code execution:
The following tool visualize what the computer is doing step-by-step as it executes the said program:
Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a Python program to find path refers to a file or directory when you encounter a path name.
Next: Write a Python program to get numbers divisible by fifteen from a list using an anonymous function.