Goals
- Learn how to run and modify an existing Python program.
- Get used to a simple programming workflow:
edit the program in a text editor (like BBEdit), save it, run it on the command line,
repeat.
- Practice using Python strings and if-statements.
Your job
- Save a copy of counter.py in
a suitable working directory on your computer.
- Read the comment at the top of counter.py, and try running the program
on a variety of input files. See whether it does what you expect it to do.
- Read through the code to make as much sense as you can of how it works.
If you have questions about how counter.py does what it does, there are many ways
to go: experiment some more to see if you can figure it out; search the internet for ideas;
ask me or your prefect or a friend or a classmate or one of the CMC lab assistants;
see if there's some insight on your question in your textbook;
post a question on our Slack #questions channel.
- Once you have gotten the hang of using counter.py, modify your copy so that in
addition to reporting the number of lines and the number of long lines,
it also does the following:
- reports the number of blank lines (i.e. lines with length zero)
- reports the number of lines with fewer than 80 characters
- reports the number of lines starting with the string "the" or "The"
- In the comment at the top of the program, change the authorship statement
to use your name instead of mine, change the date as appropriate, and add
a brief citation (e.g. "Adapted from a program written by Jeff Ondich")
- When your counter.py is ready, hand it in via Moodle. That is, login to Moodle,
go to CS111, click on the "Counting things" assignment, and use Moodle's
hand-in mechanism to submit your modified copy of counter.py.
One important detail: please make sure that your program is named "counter.py" when
you submit it. By strictly adhering to requests like this, you will be
practicing an important engineering principle ("stick to the specification!")
while at the same time making it much easier for me and the graders to grade
your work.
Start early, ask questions, and have fun!