Homework Assignment 2

Some Simple Data Processing

CS 1510
Introduction to Computing
Fall Semester 2014

Due: Thursday, September 11, at 8:00 AM


This assignment gives you your first chance this semester to write complete Python programs outside of the lab to solve problems that matter to people. Use the Python shell to develop correct expressions and the IDLE program editor to complete the programs.

Like the programs we have been writing in class and lab thus far, the basic design is IPO, input-process-output. The main task for you is to create a sequence of one or more statements that computes the desired output from the specified input data. That is one place the shell can help you: in determining the correct "pipeline" in Python for the transforming the data.

Recall our discussion of the Euro converter in Session 4. Feel free to use all that you are learning to create a clear, readable program, but be sure not to change the input/output specification. In particular, be sure that your program asks for and accepts the same number of data values specified in the requirements, and in the order specified.


For each of the following tasks, do the following:

At the end of each exercise, save your program in a file using the specified name, and save the results of your tests in the shell window to a text file named interactions.py.

Now that we are writing full Python programs, check out the course programming standards that you should follow. Coding standards are an important part of being a member of a software community. The Python and CS 1510 communities are no different.

Spec 1: Football Passer Ratings

In American football, one way of judging a quarterback's performance is passing efficiency. The NCAA uses a different formula for passing efficiency than the NFL. One of the effects of this is that the highest college passer ratings tend to be considerably higher than the highest NFL QB ratings. This means that we can't compare the numbers directly.

For example, I like to follow UNI's quarterback, Sawyer Kollmorgen. As a freshman in 2012, his passing efficiency was 141.88. I'm curious to see how that stacks up with the NFL's best.

Let's write a program to compute passing efficiency using the NFL's formula. To calculate passing efficiency, you need five inputs:

  1. the number of passes completed
  2. the number of passes attempted
  3. total passing yards
  4. number of touchdown passes
  5. number of interceptions

The NFL formula consists of five steps:

Notice that the first four steps all use per attempt values.

Using the NFL formula, Kollmorgen's 2012 passing efficiency was 95.67 -- a very good season! If you'd like to read more about passing efficiency, check out this page by an old rec.sports.football acquaintance of mine, Chris Stassen.

Name your program passing-efficiency.py.

Spec 2: Population Growth

Many public policy and economic decisions made by US businesses and governments depend on the number of people in the country. The US Census Bureau provides some raw data on population change in our country on its U.S. and World Population Clock page. As I type this, there are 318,817,034 people in the US. But it's changing fast:

Oops -- now the population is 318,817,047! All of these numbers are approximations, of course, but they can help in planning.

Let's write a program to compute the approximate population of the US on this date in any future year. Your program takes a year as input, say, 2019, and prints the population on September 5 of that year.

Use 318,817,047 as today's population. Assume that the birth, death, and migration rates stay the same throughout the entire period. Finally, assume that there are 365.25 days in a year.

Name your program population-predictor.py.


By the due date and time, submit:

Use the on-line submission system.

Make sure that your program meets the course programming standards.

Eugene Wallingford ..... wallingf@cs.uni.edu ..... September 6, 2014