Dremendo Tag Line

Check 2 digit or 3 digit positive number in Python

if elif - Question 1

In this question, we will see how to input a number and check if it is a 2 digit or 3 digit positive number or not in Python programming using the if elif statement. To know more about if elif statement click on the if elif statement lesson.

Q1) Write a program in Python to input a number and check if it is a 2 digit or 3 digit positive number or not.

Program

n=int(input('Enter a number '))

if n>=10 and n<100:
    print('Its a two digit positive number')
elif n>=100 and n<1000:
    print('Its a three digit positive number')
else:
    print('Other digit number')

Output

Enter a number 184
Its a three digit positive number
video-poster