MCS 177: Introduction to Computer Science I (Fall 2010)

Project 5: Storing Scores


Start: Thursday 10/7; Due: Wednesday 10/20, by the beginning of class

Overview

In this project, you will gain familiarity with Python's flexible "dictionary" data structure by working through a series of exercises from our textbook that are based on a highly simplified gradebook.

You are to do this project individually.

Specific tasks

  1. Do Exercise 4.24 on page 139. Your makeDictionary procedure should work with any two list (one of keys, one of values), so long as they are of the same length as each other. For example, in addition to using the two lists in the exercise, you could also have this session:

          >>> d1 = makeDictionary(['a', 'b'], [1, 2])
          >>> d2 = makeDictionary(['a', 'an', 'the'], ['indefinite', 'indefinite', 'definite'])
          >>> d1['a']
          1
          >>> d2['a']
          'indefinite'
    								

    You are not required to handle lists of unequal lengths. Be sure the parameter and variable names within your procedure are descriptive and that you avoid excessive complexity.

  2. Do Exercise 4.25 on page 139.

  3. Do Exercise 4.26 on page 139. You should complete this exercise by updating the contents of the dictionary, not by recreating it with different contents.

  4. Do Exercise 4.27 on page 139.

  5. Do Exercise 4.28 on page 139.

  6. Do Exercise 4.29 on page 139. You should complete this exercise by updating the contents of the dictionary, not by recreating it with different contents.

  7. Do Exercise 4.30 on page 139.

  8. Do Exercise 4.31 on page 139.

  9. Do Exercise 4.32 on page 139. You can use the print function to print the error message. Be sure the parameter and variable names within your procedure are descriptive and that you avoid excessive complexity.

Submitting your work

You will be submitting your code using Moodle; click on the following link for instructions on submitting code using Moodle. For this project, you will need to submit the following files:

  • gradebook.py, which is a Python file containing the Python procedures you wrote.
  • output.txt, which gives the input and output from the Python Shell window showing those portions of your work that did not consist of writing procedures.

Grading

You will earn two points for each of the following accomplishments:

  1. You have written a makeDictionary procedure that meets the stated expectations. (If it works, but is excessively complex or uses non-descriptive names, it will be worth only 1 point.)

  2. You have defined names, scores, and scoreDict as specified.

  3. You have completed exercise 4.25.

  4. You have completed exercise 4.26.

  5. You have completed exercise 4.27.

  6. You have completed exercise 4.28.

  7. You have completed exercise 4.29.

  8. You have completed exercise 4.30.

  9. You have completed exercise 4.31.

  10. You have completed exercise 4.32. (If your getScore procedure works, but is excessively complex or uses non-descriptive names, it will be worth only 1 point.)