CSE 1310-004 (Tiernan)

Lab homework IV: Assignments #1 - #2

Due date: Tuesday, Nov. 22, 12pm noon.
    No late labs accepted.

Assignment: There are two programs, Assignments #1 and #2, to write for this lab homework. You will write all of these two programs by yourself. In each assignment, write a Python program to implement the program purpose described for the assignment. You must test and run your program to make sure it works correctly before you turn the program in. For this set of assignments you are required to do input error checking as described in the assignment and as seems reasonable based on the assignment requirements. You will save your Python programs using the naming conventions defined in the lab submission instructions below.

Lab submission instructions:
1) Name each of your Python files as follows : yourlastnameFprogramname.py where "yourlastname" is replaced with your own last name starting with a small letter, the "F" is replaced with the capital letter of your first name, and "programname" is the name of the assignment you are turning in. So if the file I am turning in is Lab IV Assignment 2 then I would call my .py file tiernanClab4assnmt2.py . Abbreviations are OK as long as they are easy to understand.

2) I will activate Blackboard for this class and you will submit your assignment through Blackboard. Once I activate Blackboard for the assignments you should be able to see them when you log in to Blackboard. I reserve the right to change how/where you submit labs later in the semester if Blackboard becomes too cumbersome. Check the Blackboard instructions to determine if you should submit .py or .txt files for the assignment.

Grading: This lab homework is worth 100 points and has two programming assignments associated with it.


    Assignment #1: (40 points)
Write a Python program to read in text from a file, process it as described, and write out the results to a second file. The file will contain text with punctuation. This program will act like Lab III Assignment #2 except that for this lab you must use the built in string functions to manipulate the text that is read out of the file. Specifically you must to the following:

1) use the split function to capture the words,
2) remove all punctuation marks from the word strings using at least one string testing function, and
3) change all words to the same capitalization using string functions so that words can be sorted in complete alphabetical order.

You must still create the word count list along with the word list and you must build the lists in sorted order so that the words are alphabetical.

When the lists have been created, the program should print the completed lists and should write them to an output file with the file name "Lab4A1output.txt" The data in the file should have one word and its count on each line of the file

    Assignment #2: (60 points)
You will create a revised version of assignment #1 as follows: Write a Python program to capture words from a text file, save them and count them as described below. Words should be saved as all lower case and no punctuation marks should be included in the words.

Use the words and counts to create a dictionary. The dictionary keys will be the letters of the alphabet. Associated with each key will be a value consisting of a list. The list will contain a set of sublists. Each sublist will contain one word and its count. Build each sublist in alphabetical order but the dictionary itself, i.e. the key value pairs, can be put in the dictionary in the order they are encountered. Each word in a given dictionary will start with the letter that is the key. Ex: For a grocery shopping list, the dictionary could contain the following.

If the grocery list was:
banana
biscuit
milk
bread
banana bread

Then the dictionary would be:

{b:[[banana, 2], [biscuit,1], [bread, 2]], m:[[milk,1]]}

When complete, print the dictionary and save it to a text file (a different file than used for Assignment #1). Put the values for each key on one line with the key first.


For Lab Homework IV, the assignment grading for each assignment will consider the following aspects:
Coding:
    Comments, headers, style, modularity, readability (10% of assignment)
    Program purpose correctly implemented (20%)
    All required components included correctly (14%)
Output:
    Clearly informs user of what is required (14%)
    Performs tasks correctly (27%)
    Provides clear and complete output to user (15%)
Deductions:
    Syntax or logic errors or assignment cannot be run (-100% deduction for assignment)
    Use of library modules/functions if not explicitly listed in assignment description (-35% deduction)
    Use of elements not yet discussed in class UNLESS explicitly listed in assignment (-35% deduction)
    Use of break command (-35% deduction PER USE)
    Use of try or try/ except commands in any use other than the use specified in the lab assignment (-35% deduction PER USE)
        NOTE: if you are not sure whether to use something in Python either leave it out or ask me by e-mail

        NOTE: if you think you cannot finish the lab on time, send me an e-mail and request permission to turn your lab in late. If I allow it, I will send you and the TA a reply and the amount of late penalties by e-mail

NOTE: If you have trouble with Blackboard, send me an e-mail ASAP and attach your lab assignment to that e-mail.