This code snippet is a simple way to checks if an entered number is positive, zero, or negative. It simply checks the number if it’s greater than zero for positive output, less than zero for negative output, or equal to zero for zero output.
Python program to check if a number is zero, positive, or negative
# Take input from the user input = int(input("Please enter a number: ")) # Check the number # if the number is negative if input < 0: print("The number you entered is negative!") # if the number is positive elif input > 0: print("The number you entered is positive!") elif input == 0: # if the number is zero print("The number you entered is zero!") else: # if the user entered a non-numeric value print("The input you entered is not a number!")
Please Enter a Number: 399 The number you entered is positive!