Assignment 3
Due: 11:00 AM on Friday, September 30, 2011
Question #1
Write and document a Python script maxANchar.py which takes as
a command-line argument a textfile and computes and prints the alphanumeric
character that occurs the most times in that file along with that number of
occurrences.
Your script must work on datafiles
mc1.dat,
mc2.dat,
mc3.dat,
mc4.dat, and
mc5.dat
to produce the output given in typescript-file
maxANchar.script.
You may assume that exactly one character occurs the maximum number of times.
Question #2
A digraph is an arbitrary two-character string.
Write and document a Python script tcomp3.py which takes as
command-line arguments a master textfile, a digraph, and two or more comparison
textfiles and prints (1) the number of occurrences of the given digraph in the master
textfile and each of the comparison textfile and (2) the name of the comparison textfile
that is most similar to the master textfile relative to that digraph, i.e., the
comparison textfile whose count for that digraph is closest to the count for that
digraph in the master textfile.
Your script must work on datafiles
tc1.dat,
tc2.dat, and
tc3.dat
to produce the output given in typescript-file
tcomp3.script.
You may assume that each textfile has at most one million words and that the characters
in the digraph are arbitrary, i.e., occurrences of digraphs in the file can overlap.
Hints
You may find the answer scripts for Assignment #2 of use.
Submission
Please hand in printed copies of all of your Python script files.
You must also submit these files electronically using the
submit-assignment command.
Note that each script file must have the following comment
block at the top, where the X's are replaced with the appropriate
information, followed by a docstring briefly describing the program in that
script. For instance, my script for Question #1 of this assignment would
begin with the following comment block:
#########################################################
## CS 2500 (Fall 2011), Assignment #3, Question #1 ##
## Script File Name: cubestat.py ##
## Student Name: Todd Wareham ##
## Login Name: harold ##
## MUN #: 8008765 ##
#########################################################
You do not have to develop your code on our CS departmental systems.
However, as your code will be compiled and tested on our CS departmental
systems as part of the assignment marking process,
you should ensure that your code compiles and runs correctly on at
least one of these systems.
- August 10, 12:10pm
Assignment #3 posted.
Created: August 10, 2011
Last Modified: August 10, 2011