Answered step by step
Verified Expert Solution
Question
1 Approved Answer
PYTHON CODE, AS SOON AS POSSIBLE.. PLEASE! Write a Python age calculator program that asks for current date and birth date to calculate the present
PYTHON CODE, AS SOON AS POSSIBLE.. PLEASE!
Write a Python age calculator program that asks for current date and birth date to calculate the present age in days, months and years. In main you need to get both dates from the user and save it in two lists (current_date and birth_date). Age calculator will work only if all entered values of dates are valid (by calling validate method). Implement the following functions as follows: 1. print_date: This method takes a list as [dd, mm.yyyy) and prints the date as: dd "month in word", www. 2. valid_date: This method takes a list as (dd.mm.yyyy) and checks the validity of all the elements in the list. If all elements are valid return True. Otherwise, it will print an error message and return false. The valid date can be checked according to the following table: Month Value Day Value 1 to 31 1 to 30 1 to 28 (ignore the leap year) 1,3,5,7,8,10,12 4,6,9,11 2 Year Value 1 to current year 1 to current year 1 to current year 3 cal age: This method will calculate and print the difference between two dates. If the current days is less than that of the birth date, then that month is not counted, and subtracting days we add number of month days to the current day so as to get the difference in the day. If the current month is less than the birth month, then the current year is not taken into count as this year has not been completed and for getting the difference of months, we subtract by adding 12 to the current month. At the end we just need to subtract the days, months and years to get the difference after the two conditions are dealt with. Sample output 1: Enter Today's date as dd som yyyy: 192 2020 The entered date : 19 Feb. 2020 Enter Birth's date as dd yyyy: 24 11 1998 The entered date is: 24 Nov. 1998 Your age is 21 Years, 2 Months and 25 Days Sample output 2: Enter Today's date as dd mm yyyy: 31 2 2020 Invalid day Sorry age calculator will not work Enter Today's date ad dd mm. yyyy: 19 2 2020 The entered date 13 19 Feb. 2020 Enter Birth's date at ddmmyyyy: 24 15. 1998 Invalid month Sorry age calculator will not work Enter Birth's date as dd mm yyyy: 24 11 1998 The entered date is: 24 Nov. 1998 Your ages 21 Years, 2 Months and 25 DaysStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started