Age Category Classifier

Write a Python program that asks the user for their age and categorizes them into one of four categories: infant (below 1 year), child (1 to 12 years), teenager (13 to 19 years), or adult (20 and above). Print the category to the console.

Example:

Input: 17 

Output: You are a teenager.

Use nested if-else structures to classify the age.

age = int(input("Enter your age: "))

if age < 1:
print("You are an infant.")
elif age < 13:
print("You are a child.")
elif age < 20:
print("You are a teenager.")
else:
print("You are an adult.")

© Let’s Data Science

LOGIN

Unlock AI & Data Science treasures. Log in!