CS21 Lab 12: Dictionaries

This lab is optional.


For this lab, run update21 to get a clean copy of the file sentiment.py:

$ update21
$ cd ~/cs21/labs/12

You may want instead to start from your own final copy of lab 9:

$ cd ~/cs21/labs
$ cp 09/sentiment.py 12/sentiment.py
$ cd 12

Goals

Your job is to rewrite the sentiment analysis portion of lab 9 using dictionaries. This lab also provides an excellent way to review top-down design, reading from files, working with lists, sorting, writing for loops, and general Python syntax.

Recall that the sentiment analysis lab required the following components:


Make sure all programs are saved to your cs21/labs/12 directory.

Tips

    $ cd ~/cs21/labs
    $ time python3 09/sentiment.py
    [will print the program output, then some timing information about the program's run time]
    $ time python3 12/sentiment.py
    [will print the program output, then some timing information about the program's run time]

How much faster is your program using dictionaries, compared to your original program?

Submit

This is an optional lab, so it has no due date and will not be graded. If you are interested, once you have completed the lab, run handin21 and email your instructor to ask for feedback.