Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON Build a regular expressions based on informal specications to match specified patterns. Use a compiled regular expression in a Python program where appropriate. Use

PYTHON

  1. Build a regular expressions based on informal specications to match specified patterns.
  2. Use a compiled regular expression in a Python program where appropriate.
  3. Use Python's text processing str methods to generate a string format converter.

create a date format converter. Your program will convert a date in the format mm/dd/yyyy to the format month day, year.

Specify the required input format: mm/dd/yyyy Use a regular expression to validate the user input date format. If the format is incorrect raise a SystemExit (Links to an external site.)built-in Python exception.

Split the input string into respective month, day, and year components. Using a list to hold the month format as a string, convert the month input to the correct string month name. You will need to calculate an appropriate index to retrieve the correct month name from the month list.

Use the Gregorian calendar for valid dd:

The 12 Months

The Gregorian calendar (Links to an external site.) consists of the following 12 months:

  1. January (Links to an external site.) - 31 days
  2. February (Links to an external site.) - 28 days in a common year (Links to an external site.) and 29 days in leap years (Links to an external site.)
  3. March (Links to an external site.) - 31 days
  4. April (Links to an external site.) - 30 days
  5. May (Links to an external site.) - 31 days
  6. June (Links to an external site.) - 30 days
  7. July (Links to an external site.) - 31 days
  8. August (Links to an external site.) - 31 days
  9. September (Links to an external site.) - 30 days
  10. October (Links to an external site.) - 31 days
  11. November (Links to an external site.) - 30 days
  12. December (Links to an external site.) - 31 days

Below is an example conversion:

Enter a date (mm/dd/yyyy): 01/01/2018 The converted date is: January 01, 2018

Testing Specification

Testing Requirements: Use a loop construct to display 5 date conversions. The 1st 3 test cases should consist of valid user input. The 4th test case should be a leap year. The last 5th test case should consist of invalid user input.

Tips and Requirements

1. A list is used to store the month string names.

2. An index is calculated to retrieve the correct month from the list based on the user input.

3. A user prompt instructs the user of the expected input date format: mm/dd/yyyy

4. Obtain and validate user input. Specify a regular expression to validate the date format input by the user. Display an error message and raise a SystemExit sys.exit() if invalid.

5. The converted date output is in the format: month day, year

6. The output display: month is spelled out, the day is 2 digits dd and the year is 4 digits dddd.

7. Use named constants instead of literal values (i.e. NUM_DATES = 5).

8. Require 2 digits be supplied for mm and dd, 4 digits be supplied for year yyyy (require that the leftmost digit of the year not to be a 0). Use valid user input date range: 01/01/1000 - 12/31/2999.

Hand in only one .py file.

yournameLab4.py

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Larry Ellison Database Genius Of Oracle

Authors: Craig Peters

1st Edition

0766019748, 978-0766019744

More Books

Students also viewed these Databases questions