Question: Please use python to do this, all the files are in this link: https://drive.google.com/drive/folders/0BzoFdHKM0HX5UmE2cUtMU1Y4WGc?usp=sharing Please show me all the steps to run this code

Please use python to do this, all the files are in this link:

https://drive.google.com/drive/folders/0BzoFdHKM0HX5UmE2cUtMU1Y4WGc?usp=sharing

Please show me all the steps to run this code

""" CMPUT 175 LAB 8

Tasks: 1. Please read the comments first. 2. Construct regular expressions for the two formats (line 17-30). 3. Complete the main, extract_date and check_date functions. """

import re import sys

month_names = ["january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december"]

''' Construct regular expressions for the following two date formats: 1. // where contains 4 digits; and contain 1 or 2 digits. (e.g. '11/05/2017', '06/02/2000', '6/2/1999') 2. where contains 4 digits; is a name for a month (see the variable month_names); contain 1 or 2 digits. (e.g. '18 March 2007', '1 October 1999', '2 june 2015')

You can assume that there are no digits that precede or follow the date in the string. ''' re1 = "" re2 = ""

def extract_date(string): ''' Extract the date from the string using re.match(, ). Since we initialze re1 and re2 as global variables, we can use them in this function. Then use .group() or .groups() to get the match strings. If there is a match, return [, , ] where , and are integers. If there is no match, return an invalid date (e.g, [0, 0, 0]).

Arg: string - a string

Return: [, , ] - a list of integers ''' return [0, 0, 0]

def check_date(day, month, year): ''' Check if the date is valid or not: 1. The month must be in the range [1,12]. 2. Some months have 31 days, some have 30 day, one has 28 days. If you don't know the rule, check out this link https://en.wikipedia.org/wiki/Month. You can assume that there is no leap year in the input.

Arg: day - an integer month - an integer year - an integer

Return: a Boolean value ''' return True

def main(): ''' The function reads input from stdin (line by line), extracts date in each line, checks if the date is valid and then output the message. ''' for line in sys.stdin: ''' Call extract_date() to get the date information. Remember to remove the new line char and make be lowercase. ''' # [day, month, year] = extract_date()

''' If there is a valid date, output the date in the format: "(year, month, day)". If there is no valid date, output "no date detected". ''' # if check_date(day, month, year): # do something # else: # do something

if __name__ == "__main__": main()

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!