check a number is positive negative or zero

Check a number is positive, negative or zero in python

Introduction

In this post, you will learn how to check a number is positive, negative or zero in python and below is the video format of the post, check it out.

Video

Check a number is positive, negative or zero in python source code

Before we get into the subject you need to know about ????????

  1. if else
  2. operators
  3. Data types

Source code: if,else,elif

Here firstly, I have entered the variable num and asked the user to input the value and the data type is float and then I added an if statement that if num is greater than zero then it is positive.

Then I added the elif statement and said elif less than zero and the print as negative and then finally the else statement is zero.

Output:

Check a number

Source Code: Using Nested if

Here also, I did the same as before but it is nested if else statement.

Output:

Check a number

Below is a run option where you can run the program ????????


Also Read: Heads or tails in python full tutorial

Also Read: Random module in python

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions or brave browser to block ads. Please support us by disabling these ads blocker.Our website is made possible by displaying Ads hope you whitelist our site. We use very minimal Ads in our site

 

Scroll to Top