How to Check if a Number is Positive or Negative in Python

 How to Check if a Number is Positive or Negative

In this program, we will learn how to check whether a number or an integer entered by a user is positive, negative or zero. We will use the if, elif and else statement to check the input. As we all know, any number greater zero is a positive number and any number less than zero is a negative number


number = int(input('ENTER A NUMBER:  '))

if number > 0:

print('THE NUMBER IS POSITIVE')

elif number < 0:

print('THE NUMBER IS NEGATIVE')

elif number == 0:

print('THE NUMBER IS ZERO')

else: 

print('ERROR! ENTER A NUMBER NEXT TIME')

Now let's how we can program this




 TAKING USER INPUT


When the enters a positive number


 

When the user input a negative number




When the user input zero


Subscribe My YouTube Channel and Follow Me

YouTube

TikTok 

Twitter

Facebook 

Post a Comment

0 Comments