Course Home | Class Schedule | Assignments | Git Submission | Perusall | Python | Tutoring

Saint Louis University

Computer Science 1300/5001
Introduction to Object-Oriented Programming

Michael Goldwasser

Fall 2018

Computer Science Department

Homework Assignment 13

Error Checking and Exceptions

Overview

Topic: Input, Output and Files
Related Reading: Chapter 14
Due: 10:00am, Friday 19 October 2018

Please make sure you adhere to the policies on academic integrity.


Problem to be Submitted (20 points)

For this homework, we ask you to do the following warmup challenge that will begin the in-class lab. For this reason, please prepare a hardcopy of your solution to turn in at the beginning of class, but also keep an additional copy for yourself (whether electronic or hardcopy).

The linked file states.csv has one line for each of 50 states, with comma-separated values that provide the name of the state followed by a sequence of integer values. We'll explain the significance of those values when we beginning the in-class activity, but in preparation you are to write a Python script that does the following.

Open the file and parse the data so that you create a list named states where each entry of that list has the following form:

( stateName, [ list of integers ] )

For example, for Alabama the file has a line which is the string

'Alabama,4779736,3362877,1259224,32903,55240,5208,64284'
but we would like you to have computed the tuple
('Alabama', [4779736,3362877,1259224,32903,55240,5208,64284] )
where it is important that the list is a list of integers (not a list of the strings that originally portrayed those integers), as this prepares us for doing subsequent calculations with those nubmers.

If you are successful, you will have in effect set the variable

states = [
  ('Alabama', [4779736,3362877,1259224,32903,55240,5208,64284] ),
  ('Alaska', [710231,483873,24441,106268,38882,7662,49105] ),
  ...
]

Submit (on paper) the source code that accomplishes this task.


Michael Goldwasser
CSCI 1300/5001, Fall 2018
Last modified: Wednesday, 17 October 2018
Course Home | Class Schedule | Assignments | Git Submission | Perusall | Python | Tutoring