Source Code: Using if...elif...else
Here, we have used the if...elif...else statement. We can do the same thing using nested if statements as follows.
Source Code: Using Nested if
The output of both programs will be the same.
Output 1
Enter a number: 2 Positive number
Output 2
Enter a number: 0 Zero
A number is positive if it is greater than zero. We check this in the expression of if. If it is False, the number will either be zero or negative. This is also tested in subsequent expression.