Examining Olympic Medal Counts

Objective: Get more practice with loops, conditionals, and files


Code due by Wednesday, March 22nd at 11:00 AM
(but get it done before you leave for Spring Break...)

An introduction

We will look at the idea of how many olympic medals were won by a country compared to it's population. The 2014 population of the medal-earning countries that participated in the Sochi winter olymipics was 2,516,757,975 people. Further, 295 medals were won in the winter olympics in Sochi.  This means that there were:

295 / 2,516,757,975 * 10,000,000 =1.172 medals awarded for every 10,000,000 people

For each country, we can use it's population and it's medal count to calculate whether it was above average, below average, WELL above average, or WELL below average based on:

Ratio Result
Less than 0.672 WELL Below Average
0.672 - 1.171 Below Average
1.172 Average
1.173-1.672 Above Average
Greater than 1.672 WELL Above Average

The Assignment

Download the following data from the 2014 Winter Olympics in Sochi:

This is a text file (although it is likely that your operating system will recognize it as openable by Excel and give it an Excel icon).  Open this file with either Excel or a basic text editor.  Notice that this file consists of a header line and then a sequence of data consisting of comma separate fields of country name, population, and medal count.

Write a program (called that:

Once you get that working, modify the program to write to a file called results.txt rather than print to the screen.

HINT: Use the round function to round your computations to 3 decimal places. For example:

Finally, after you have finished writing to the results.txt file, print the country with the highest and lowest ratios.

NOTE: You do NOT need to use functions in this assignment.

Final Submission

Please prepare all of this in a file called  .

To upload your homework for grading, log on to eLearning, select this class, and navigate to the "Assignment Submissions" area. Click on the "Programming Assignment 6" folder and upload the python file in the designated location.