Question: In Python Extract Data and Convert: The task at hand is to create a date format converter. The program will convert a date in the

In Python Extract Data and Convert: The task at hand is to create a date format converter. The program will convert a date in the format mm/dd/yyyy to the format month day, year.

Prompt the user for a data input. Specify the required input format to be: mm/dd/yyyy Use a regular expression to validate the user input date format. If the format is incorrect raise a SystemExit.

Steps your program takes:

1. Split the input string into respective month, day, and year components.

2. Define a list to hold the month labels/names, formatted as a string. Then your algorithm converts the month input to the corresponding string month label/name. You will need to calculate an appropriate index to retrieve the correct month name from the month list.

3. Check for dd exceeded day range, except February, in accordance to the Gregorian calendar: April, June, September and November have 30 days and all the rest 31 days.

4. For mm referring to February, use this rule, in accordance to the Gregorian calendar, to determine if yyyy entered is a leap year or not, for validating dd in range:

not( year % 400) or ( not ( year % 4) and (year % 100) )

Sample record of execution:

Enter a date (mm/dd/yyyy): 03/09/2021 The converted date is: March 09, 2021

1. Test requirements - Use a loop construct to display 5 date conversions. The 1st 4 test cases should consist of valid user input. The last, 5th , test case should consist of invalid user input.

2. Define a list to hold the month labels/names, formatted as a strings, to be used for filling out the converted month values.

3. A user prompt instructs the user of the expected input date format, as shown above: mm/dd/yyyy. It requires 2 digits be supplied for mm and dd, 4 digits be supplied for year yyyy (the leftmost digit of the year not to be a 0). Use valid user input date range: 01/01/1000 - 12/31/2999.

4. Obtain and validate user input. Display an error message and raise a SystemExit if invalid. The error messages should read, for example, "Date input error or out of range".

5. Base on the input value, an index is calculated to retrieve the corresponding month from the list, from step 2.

6. The converted date output is in the format: month day, year ; month spelled out, day in 2 digits and year in 4 digits, as shown in the sample above.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!