CSC108H Assignment 3

Assignment 3
Due Apr 10 by 1pm Points 8 Available after Feb 29 at 9am
Recent updates
22 Mar The assignment submission system, MarkUs, is available, but the online style checking is not. We will send an announcement when it is
CSC108H Assignment 3
Deadline: 10 April 2020 by 1:00pm
Late policy: There are penalties for submitting the assignment after the due date. These penalties depend on how many hours late your submission is.
Please see the syllabus on Quercus for more information.
Please do not violate the U of T Code of Student Conduct
Please do not look for extra help outside the course resources. It is disheartening. We have investigated and are interviewing more than four dozen students
in CSC108 for academic offences in Assignment 2 (although some have been delayed due to COVID-19).
The reasons we have heard are typical of what we hear every semester. They are discussions ranging from someone who had an upper-year CS friend
helping them and that person was also helping someone else too much by sharing that same code, or a roommate was stuck and so they worked together
for a bit, or they posted their code on WeChat or similar for feedback and other people copied it.
Please don’t do any of that, or read your code over the phone to your friend, or steal someone’s code, or use a tutoring service to write it with you, or have a
friend back home do most of it for you. The U of T has a Code of Student Conduct
( . It’s only 12 pages long, and describes your rights and
responsibilities related to the U our university. If you’re looking for something to do, it’s probably worth a read!
We use a program that detects similarities. It works even if you rename everything and move blocks of code around: it looks for sequences of statements
with similar structure, wherever they may be.
We have regular TA and instructor office hours and are happy to help! During lecture times, the instructor and classroom TAs are available, and we can help
you in a private voice and text chat using Blackboard Collaborate. Please come visit if you’re stuck on A3!
If you come for help, please first submit your code on MarkUs. Remember that you can submit a file as many times as you like, there is no limit! That way the
we can look at your code directly, and even share our screens with you while we discuss your issue.
If you normally rely on too much help, try to work on your own more for this assignment, and come visit office hours as many times as you like!
In this assignment, you will write a program to analyze poetry, counting syllables and looking for rhymes.
This handout explains the problem you are to solve and the tasks you need to complete for the assignment. Please read it carefully.
Goals of this Assignment
Write function bodies using dictionaries and file reading.
Write code to mutate lists and dictionaries.
Use top down design to break a problem down into subtasks and implement helper functions to complete those tasks.
Write tests to check whether a function is correct.
Files in the download
Please download the Assignment 3 files and extract the zip archive.
Starter code: and
These are the only files you need to modify and submit. These two files contain the headers for the functions you will need to write for this
assignment, and a few completed function docstrings. Many of these functions will be called by the main program ( ). You can, and should,
write some helper functions in this file. Your lives will be easier if you do.
Helper module: poetry_constants .py
Read this! This file contains several definitions of new types that we use in the function type annotations.
Main Program:
Run this first. The file contains a program that calls the functions in the starter code files. You can run it now, although it won’t work properly until you
complete the functions in the starter files. Still, you’ll be able to use this to check your progress.
Data: poetry/*.txt
In the poetry directory are several files containing poems that you can use to test your code.
Data: dictionary.txt
This file contains a huge list of English words and their pronunciations.
Data: poetry_forms.txt
This file contains information describing various poetic forms.
We have provided a checker program that you should use to check your code. See below for more information about .
Poetry Forms
Poetry differs from prose because it has a fixed structure. Different forms of poetry, such as sonnets and haiku, have rules about which words must rhyme
and the number of syllables in each line.
In this assignment, you will write a program to read a poem from a file, figure out the pronunciation, count the number of syllables in each line, and determine
which lines rhyme.
Some poetry forms specify the number and order of stressed and unstressed syllables within a line. We will not consider syllabic stress in this assignment.
Some poetry forms specify that particular words must alliterate, or start with the same sound. We will not consider alliteration in this assignment.