In this program, you will learn how to check the given number is positive or nagetive number.
# This program to check the number is positive or negative
#num = -12
num = int(input('Enter the number: '))
#if the number is greater than 1
if num > 0:
print('The number {0} is a positive number'.format(num))
elif num < 0:
print('The number {0} is a negative number'.format(num))
elif num == 0:
print('The number is Zero')
else:
print('The input is not valid')
Enter the number: -15
The number -15 is a negative number
In general, you will need to check wehther the number is positive or negative number.
In this program, the variable num is used to holds the given number.
First, check the given number is positive by checking num value is greater than 0.
Then, check the given number is negative by checking num value is less than 0.
Then, check the given number is 0.
Finally, check the given number is invalid number.
In this program, the given number is -15. So, the condition, the number is less than 0 is satisfied and prints the output "The number -15 is a negative number"
The following topics can be useful to understand this program.