Answer to Question #199459 in Python for Angelie Suarez

Question #199459

Activity:

Create a program that accepts birth year and current year. Define a function that has 2 parameters: birthyear

and presentyear then it will calculate and returns the age. Define another function that will determine if the

age is minor or legal age.


FINISHED CODE:

def getAge():

def validateAge():

byear = int(input("Enter Birth Year:"))

pyear = int(input("Enter Present Year:"))

age = getAge()

validatedAge = validateAge()

print(f "Your age is {age} and it is {validatedAge}")


sample output:

Enter Birth Year: 1992

Enter Present Year:2021

Your age is 29 and it is legal


1
Expert's answer
2021-05-27T07:55:39-0400
def getAge():

	byear = int(input("Enter Birth Year:"))
	pyear = int(input("Enter Present Year:"))
	currentAge = pyear - byear

	return currentAge

def validateAge(age):

	if (int(age) >= 18):
		status = "legal"
	else:
	    status = "minor"

	return "Your age is " + str(age) + " and it is " + status

print(validateAge(getAge()))

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS