Question
Please use python to do this, all the files are in this link: https://drive.google.com/drive/folders/0BzoFdHKM0HX5UmE2cUtMU1Y4WGc?usp=sharing CMPUT 175 LAB 8 Tasks: 1. Please read the comments
Please use python to do this, all the files are in this link:
https://drive.google.com/drive/folders/0BzoFdHKM0HX5UmE2cUtMU1Y4WGc?usp=sharing
""" 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.
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(
Arg: string - a string
Return: [
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(
''' 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
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