Positive Negative Zero
Table of Contents
In this tutorial, we will discuss the Python code to check whether the given number is positive or negative or 0
In this post, we are going to learn how to check whether the given number is positive or Negative or zero using 3 ways in Python language
The logic to check positive, negative or zero
Program 1
#Pyton program to check number is positive or negative or zero
num=234
if(num>0):
print("{0} is a positive number".format(num))
elif(num<0):
print("{0} is a negative number".format(num))
else:
print("you have entered zero") When the above code is executed, it produces the following result
234 is a positive number
In this program,
Program 2
#Pyton program to check number is positive or negative or zero
num=int(input("Enter the number: "))
if(num>0):
print("{0} is a positive number".format(num))
elif(num<0):
print("{0} is a negative number".format(num))
else:
print("you have entered zero") When the above code is executed, it produces the following result
Case 1
Enter the number: 124 124 is a positive number
Case 2
Enter the number: -765 -765 is a negative number
Case 3
Enter the number: 0 you have entered zero
Approach
Program 3
#Pyton program to check number is positive or negative or zero
num=int(input("Enter the number: "))
def FindPositive():
if(num>0):
print("{0} is a positive number".format(num))
elif(num<0):
print("{0} is a negative number".format(num))
else:
print("you have entered zero")
#FindPositive(); When the above code is executed, it produces the following result
Case 1
Enter the number: 36 36 is a positive number
case 2
Enter the number: -75 -75 is a negative number
case 3
Enter the number: 0 you have entered zero
Approach
Suggested post
Similar post
Java program to find if the given number is positive or negative or 0
C program to find if the given number is positive or negative or 0
C++ program to find if the given number is positive or negative or 0
Multiply two numbers in Java using scanner| 5 different ways In this article, we will…
5 Different ways to Divide two numbers in Java using scanner In this article, we…
Learn 8 Ways to Subtract Two Numbers Using Methods in Java In this article, we…
10 ways to subtract two numbers in Java In this article, we will discuss the…
Java Code Examples – Multiply Two Numbers in 5 Easy Ways In this article, we…
How to Divide two numbers in Java| 5 different ways In this article, we will…
This website uses cookies.