The document contains two Python code snippets that check if a user-input or predefined number is positive, negative, or zero. The first snippet checks if the number 3 is positive or negative and prints the corresponding message. The second snippet prompts the user to input a number, checks if it is positive, negative, or zero, and prints the corresponding message.
The document contains two Python code snippets that check if a user-input or predefined number is positive, negative, or zero. The first snippet checks if the number 3 is positive or negative and prints the corresponding message. The second snippet prompts the user to input a number, checks if it is positive, negative, or zero, and prints the corresponding message.
The document contains two Python code snippets that check if a user-input or predefined number is positive, negative, or zero. The first snippet checks if the number 3 is positive or negative and prints the corresponding message. The second snippet prompts the user to input a number, checks if it is positive, negative, or zero, and prints the corresponding message.
# Program checks if the number is positive or negative
# And displays an appropriate message num = 3 # Try these two variations as well. # num = -5 # num = 0 if num >= 0: print("Positive or Zero") else: print("Negative number") #To check number is positive or negative num = float(input("Enter a number: ")) if num >= 0: if num == 0: print("Zero") else: print("Positive number") else: print("Negative number")