Respuesta :
The console application that requests the user to enter the name of their Pet and the year their pet was born and calculate its age is as follows:
from datetime import date
def nameAndAge(x, y):
today = date.today()
age = today.year - y.year - ((today.month, today.day) < (y.month, y.day))
return f"The name of your pet is {x} and the age is {age}"
# Driver code
print(nameAndAge("mike", date(1997, 2, 3)), "years")
Code explanation
The code is written in python.
- we have to import date from datetime module.
- We declared a function named "nameAndAge". The arguments of the function are the users input which are the name and date of birth of the pet.
- We store todays date in the variable called "today".
- Then we calculate the age of the pet.
- The next line of code, we returned the name and the age of the pet base on the users input.
- Finally, we call the function with the print statement.
learn more on python here: https://brainly.com/question/25285677
