Course Home | Class Schedule | Moodle CMS | Git Submission | Perusall | Tutoring

Saint Louis University

Computer Science 1300/5001
Introduction to Object-Oriented Programming

Michael Goldwasser

Fall 2019

Computer Science Department

Homework Assignment 15

Input, Output and Files

Overview

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


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 2019
Last modified: Sunday, 22 December 2019
Course Home | Class Schedule | Moodle CMS | Git Submission | Perusall | Tutoring