Homework Assignment Number 9

  1. Read Chapter 7

  2. Create program that replaces holidays with dates

    1. Create a dictionary of 8 or more holidays for 2011 listing dates as strings of the form '12/25/2011' (e.g., Christmas)

      • For simplicity, please either choose one word holidays or hyphenate multi-word holidays, e.g., Veteran's-Day

    2. Write a function that uses the dictionary to replace holidays in a string with the
      corresponding dates. The function should work as follows:

      • It should splits the string into words (use the split function)

        • To simplify the problem, hyphenate any multi-word holidays, e.g., Veteran's-Day

      •  It should check if each word is in the dictionary and replace it in the list with its value, e.g., the list ['I','wish','you','a','merry','Christmas'] should become: ['I','wish','you','a','merry', '12/25/2011']

      • Converts this list into a string using a for loop. Start with the empty string and add the items in the list, separated by spaces. Return the resulting string.

      • Your function in (ii) should deal with punctuation and capitalization in some way. For capitalization, you could simply convert to lower case and only store lowercase items in your dictionary. For punctuation, you could strip off characters that are neither letters, nor numbers. In other words, you could go through each word and check the last letter. If the last letter is a letter or number, you would leave it alone. Otherwise, you could chop off the last letter. Later on you could add a period to the end of all sentences. Smoother ways of handling these issues are worth more points.

Grading Criteria

  1. Does your programs work?

  2. Does it solve the problem?

  3. How well do you handle the capitalization/punctuation issues

  4. Is your code clearly written, elegant and/or clever