Code due by Monday, March 19th at 9:00 AM
(but get it done before you leave for Spring Break...)
We will look at the idea of how many olympic medals were won by a country compared to it's population. The 2018 population of the medal-earning countries that participated in the PyeongChang 2018 Winter Olymipics was 2,460,774,720 people (excluding Russia). Further, 290 medals were won (again, excluding Russia). This means that there were:
290 / 2,460,774,720 * 10,000,000 =1.178 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:
|Less than 0.672||WELL Below Average|
|0.672 - 1.177||Below Average|
|Greater than 1.672||WELL Above Average|
Download the following data from the 2018 Winter Olympics in PyeongChang:
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, medal count, and a population.
Write a program (called pa06.py) that:
Once you get that working, modify the program to write to a file called results.csv rather than print to the screen. The results.csv file should be formatted similarly to the medalData.csv file.
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 to the screen (not to the text file) the country with the highest and lowest ratios.
Please prepare all of this in a file called pa06.py .
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.