Computer Science, asked by sivakami1848, 15 days ago

write a pprogram to input an age of a person and she is a kid , youth , middle aged or aged ? <15 kid , < 35 youth , <55 middle aged , < 100 aged person

Answers

Answered by Anonymous
3

The question is being answered by assuming that the user has asked it for python.

Required program:-

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

If n <15 and (n>0):

print ("You are a kid")

elif n < 35 and (n>0):

print ("You are youth")

elif n<55 and (n>0):

print ("You are middle aged")

elif n<100 and (n>0):

print ("You are aged person")

else:

print ("You have entered a wrong age")

Explanation :-

  • Firstly you have to take the age of user as input in the form of integer and storing it in a variable n. int() function will take the input as integer.

  • Now using an if else ladder to print different statements at different ages.

  • You have to declare that age is not smaller than 0 either the program will print "You are a kid".

  • If the user has entered an age greater than 100, the program will print the statement "You have entered a wrong age".

Similar questions