In this python if else program, we will check whether the given number is negative or not.
Negative number:
A negative number is any number that is less than zero.
Steps to solve the program
- Take a number as input through the user.
- If the number is negative then print True, else print False.
- Use an if-else statement for this purpose.
- Print the output.
num = int(input("Enter a number: "))
if num<0:
print("True")
else:
print("False")
Output :
Enter a number: -45
True
Related Articles
Python program to check whether the given number is positive or negative and even or odd.
Python program to print the largest number from two numbers.
Python program to check whether a given character is uppercase or not.
Python program to check whether the given character is lowercase or not.
Python program to check whether the given number is an integer or not.
Python program to check whether the given number is float or not.