Python Program to Find if the Number is Positive,Negative or Zero

 

Topic: To check whether a number is Positive, Negative or Zero

Hey Guys, today we are going see a Python Program to check whether a number is Positive, Negative or Zero.

Title: Python Code to check whether a number is Positive, Negative or Zero. (Beginner Friendly+ Easy + Code + Output + Online Compiler)


What is this program and why we are going to use it?

This Program consists of Variables, Input Function, Conditional Statement and Comparison Operator.

By using variable, we are going to store values in variables in int or float format according to our use. By using input function, we are going to input values from the user. For Eg. storing the values:
a=5
here a is a variable where 5 is assigned to a and 6 is assigned to b.

Now for input function

a = int(input("Enter Num a:"))
So, this will ask user to input a number.

Logic:

We will First Check
1. if the number is zero. If it is then we will print it as zero.
2. elif we will check whether the number is positive. If the Number is Positive it will print as Positive.
3. else it will print the number as negative as both conditions are not satisfied. 

Code:


Online Compiler (Switch to Interactive Mode before execution):



Applications:
1. To check whether number is +ve , -Ve or zero. 

Comments