Spring 2017 CSCI 373 Homework 8

This assignment is due by 5:00 PM Tuesday, 28 March.

A Python prep assignment

This is an assignment to jump-start you on Python and make sure you know enough Python to use the os and subprocess modules by the 12 April meeting.

Preparation

Work through the first three parts of Python for Java Programmers. This will take you up to text files and dictionaries.

As you work through the sections, type in (ok... copy-and-paste) the examples and run them. That will help you to learn Python.

The assignment

Write a program so that can be run from the command line as follows:
    wordcount file
You can do this using the hashbang feature of Linux simply by starting your Python command with the Python comment
    #!/usr/bin/env python

Your program will open file.txt as an input file and create file.count as an output file.

Your program should count the number of times each letter of the alphabet appears in the input file. For every unique letter that appears in the file, your output file should contain a line the lists that letter followed by the number of times it appears in the file. All letters should be converted to upper case before performing the count.

For example, suppose the input file contains the following text:

    For example, suppose the input file contains the following text:

Then your program should the following in the output file.

A    2
C    1
E    7
F    3
G    1
H    1
I    4
L    4
M    1
N    4
O    5
P    4
R    1
S    3
T    6
U    2
W    1
X    2

Yet more references

There are a lot of Python cheat sheets on Pinterest.

Turn in

Upload your Python program (no PDF) to the Homework 8 moodle page by 11:00 PM on Saturday, 8 April.