

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


For this assignment you are to create and submit a single Python module named āhw3.pyā containing definitions for the following functions (with precisely these spellings):
You will also need the function GetTokens from the previous assignment, which you must include in this file. (As always, you may also include any other functions that you deem necessary.) You may either use your own version of GetTokens, or the version that will be posted for you on the downloads page. If you use your own version, make sure it works correctlyāyou would not want to lose points twice for the same mistake! This assignment has two objectives: To familiarize you with reading and writing to files, and to give you some practice in writing programs that catch and handle errors. Here is what you need to do:
{āBatā: 1, ā,ā: 3, ācatā: 2, ābatā: 1, ā !ā: 1} (1)
Note that āBatā and ābatā are distinct due to capitalization. Recall that you can test whether a key is already in a dictionary using the āinā operator, and you can increment an integer
associated with a key using the ā+=ā operator; e.g. d["cat"] += 1 increments the count associated with the word ācatā if it is already present in the dictionary.
Test cases that you can use to check your functions will be posted for you on the downloads page. Be sure to test your functions thoroughly. Also, remember to document your functions so they are intelligible to the grader.
You will need to understand how to use open, readline, close, .keys(), .items(), .sort(), try, except, raise, and the ā%ā operator for formatting strings (among other things) to do this assignment. You may use GetTokens, IsAlphabetic, and upcase from the posted solutions and samples if you wish.