Find out given input belongs to which group

In this python nested if else program, we will find out given input belongs to which group.

Steps to solve the program
  1. Take a number between 1-100 as input through the user.
  2. Create 10 groups of numbers between 1-10. Each group will have 10 numbers (i.e. 1-10,11-20,….,91-100) using nested if-else statements.
  3. With the help of nested if-else statements check the input number lies in which group.
  4. Print the respective output.
				
					num = int(input("Enter a number: "))

if 1<= num <=10:
    print("The given number belongs to 1st group")
elif 11<= num <=20:
    print("The given number belongs to 2nd group")
elif 21<= num <=30:
    print("The given number belongs to 3rd group")
elif 31<= num <=40:
    print("The given number belongs to 4th group")
elif 41<= num <=50:
    print("The given number belongs to 5th group")
elif 51<= num <=60:
    print("The given number belongs to 6th group")
elif 61<= num <=70:
    print("The given number belongs to 7th group")
elif 71<= num <=80:
    print("The given number belongs to 8th group")
elif 81<= num <=90:
    print("The given number belongs to 9th group")
elif 91<= num <=100:
    print("The given number belongs to 10th group")
else:
print("Invalid number")
				
			

Output :

				
					Enter a number: 36
The given number belongs to 4th group
				
			

Related Articles

check the eligibility of a person to sit on a roller coaster ride or not.

find employees eligible for bonus.

Leave a Comment