Dremendo Tag Line

Check number is positive, negative or zero in Python

if elif - Question 2

In this question, we will see how to input a number and check if it is a positive number or a negative number or a zero in Python programming using the if elif statement. To know more about if elif statement click on the if elif statement lesson.

Q2) Write a program in Python to input a number and check if it is a positive number or a negative number or a zero.

Program

n=int(input('Enter a number '))

if n>0:
    print('Positive number')
elif n<0:
    print('Negative number')
else:
    print('Zero')

Output

Enter a number -5
Negative number
video-poster