Write a Python Program to Check if a Number is Positive, Negative or 0

Python Program to Check if a Number is Positive, Negative or 0

Welcome to the World of Online Learning:

Hello Friends “This blog helps you to learn  Python programming concepts. You can learn Python language at your own speed and time. One can learn concepts of Python language by practicing various programs given on various pages of this blog. Enjoy the power of Self-learning using the Internet.”

Python Program to Check if a Number is Positive, Negative or 0
Python Program to Check if a Number is Positive, Negative or 0

Write a Python Program to Check if a Number is Positive, Negative or 0

PROGRAM: Python Program to Check if a Number is Positive, Negative or 0

/*Python Program to Check if a Number is Positive, Negative or 0 */
1.Using if...elif...else
num = float(input("Enter a number: "))
if num > 0:
print("Positive number")
elif num == 0:
print("Zero")
else:
print("Negative number")

Output 1

Enter a number: 2
Positive number
2.Using Nested if
num = float(input("Enter a number: "))
if num >= 0:
if num == 0:
print("Zero")
else:
print("Positive number")
else:
print("Negative number")
Output 2
Enter a number: 0
Zero

Leave a Reply

Your email address will not be published. Required fields are marked *