关键词 > Python代写
[Coding exercise] Week 5 - Vaccination Analysis
发布时间:2021-02-24
[Coding exercise] Week 5 - Vaccination Analysis
Due Monday by 11:59pm
Points 20
Submitting a file upload
File Types zip
Available Feb 10 at 10:30am - Feb 24 at 11:59pm 15 days
Now that suitable vaccines to protect against COVID-19 are available, the next step is for countries to vaccinate their populations as quickly as possible. In this exercise we will build a program to help us see how successful the vaccination programs for various countries have been so far.
Download Data File
The following is a data file containing vaccination statistics by country (taken and modified from the Humanitarian Data Exchange (https://data.humdata.org) ): [vaccinations.csv].
● The first row has a description of each column.
● Each row after that contains one day's cumulative vaccination data for one country.
● The last row of data for each country contains the most recent vaccination data for that country.
Have a careful look through this data file and make sure you understand how it is structured before moving on.
Part 1: Output Country Data
Write a Python program named part1.py that outputs the percentage of people in each country that have been vaccinated, using the most recent data available in the CSV file. The column labelled total_vaccinations_per_hundred is the one to focus on.
Hint: create a dictionary to store the percentage value for each country. For one country, this percentage value can be updated multiple times until you have the most recent value stored.
Here is sample output showing the data for the first few countries in the CSV file:
Notes:
● You should ignore any rows of the file that have either a blank or a value of zero for the total_vaccinations_per_hundred.
● Percentages should be output with exactly one digit after the decimal point.
Part 2: User Interaction & Statistics
Write a Python program named part2.py that asks the user to input a country name, and outputs the following information:
● The vaccination percentage for the country the user chose.
● The average vaccination percentage for all countries in the CSV file.
● The country with the lowest vaccination percentage out of all countries, as well as the actual lowest vaccination percentage value found.
● The country with the highest vaccination percentage out of all countries, as well as the actual highest vaccination percentage value found.
Here are two sample runs:
Notes:
● The percentages and countries in the above sample runs do not represent actual data calculated from the given CSV file; they are only intended to show you what your output should look like.
● Copy the part1.py program from part 1 to part2.py as a starting point.
● Your program must accept any case for the user input. E.g., Canada, canada, and cAnADA would all be recognized as the same country
● If the user gives a country name that does not exist in the file, you should output a message stating so.
● You should ignore any rows of the file that have either a blank or a value of zero for the total_vaccinations_per_hundred.
● Percentages should be output with exactly one digit after the decimal point.
● If more than one country has the highest or lowest vaccination percentage, you can choose any of those country's names to output.
General Notes
● In IDLE, you can run and test each of your two Python files directly, which is what the TAs will do.
● If you wish to code in repl.it, you can add multiple files to your REPL. Remember to upload the data file, too. When you want to work on a question, copy the contents to main.py to test them, one by one, but remember to put the code back into the corresponding .py file. When you're done, use the Download as.zip function. Note, the main.py file will be included, but it won't be marked. Only part1.py and part2.py will be marked.
● We may use a different data file (but with the same file name and structure) to mark your assignment's correctness. So don't "hard code" anything.
● You must write Python code that calculates and prints out the answers to the questions, by analyzing the .csv file. You get no points just for answering the questions (e.g. finding the answer using Excel and printing it).
Readability Guidelines
Please check that your code follows the guidelines here: readability guidelines
Submission
Submit a single .zip file containing your 2 Python files (part1.py and part2.py). This is the code that will be marked. If you include a file named main.py it will not be marked.
Make sure you also complete the separate week 5 reflection activity.
Marking Notes
● If your program does not run (i.e. crashes or produces an error), your mark will be calculated using the rubric and then multiplied by 0.5. To avoid this penalty, try to finish early so you can get help from TAs if needed! It is better to submit code that works perfectly but doesn't contain all the features, than one that has all the features (potentially) but crashes.
Week 5 Rubric
Criteria
|
Ratings
|
Pts
|
||
Submitted two .py files in .zip file
|
1 pts
Submitted in requested format
|
0 pts
Not as requested
|
1 pts
|
|
part1.py: Output countries
|
2 pts
Correct answer
Program has correct
answer using sensible
Python code
|
1 pts
Incorrect answer
Program uses partial
list using sensible
Python code
|
0 pts
Insufficient
Didn’t answer question,
or answer is extremely
wrong.
|
2 pts
|
part1.py: Output percentage for each country
|
1 pts
Correct answer
Program calculates and prints the correct
answer using sensible Python code
|
0 pts
Insufficient
Didn’t answer question, or
answer is extremely wrong.
|
1 pts
|
|
part1.py: Output correct value for each country
|
1 pts
Correct answer
Program calculates and prints the correct
answer using sensible Python code
|
0 pts
Insufficient
Didn’t answer question, or
answer is extremely wrong.
|
1 pts
|
|
part1.py: List does not contain countries with
missing or 0 values
|
1 pts
Correct answer
Program calculates and prints the correct
answer using sensible Python code
|
0 pts
Insufficient
Didn’t answer question, or
answer is extremely wrong.
|
1 pts
|
|
part1.py: Values shown with one digit after the decimal
point
|
1 pts
Correct answer
Program calculates and prints the correct
answer using sensible Python code
|
0 pts
Insufficient
Didn’t answer question, or
answer is extremely wrong.
|
1 pts
|
|
part2.py: Accepts user input for country
|
1 pts
Correct answer
Program calculates and prints the correct
answer using sensible Python code
|
0 pts
Insufficient
Didn’t answer question, or
answer is extremely wrong.
|
1 pts
|
|
part2.py: Accepts user input in lower or upper case (or
both)
|
1 pts
Correct answer
Program calculates and prints the correct
answer using sensible Python code
|
0 pts
Insufficient
Didn’t answer question, or
answer is extremely wrong.
|
1 pts
|
|
part2.py: Outputs error message for invalid country
name
|
1 pts
Correct answer
Program calculates and prints the correct
answer using sensible Python code
|
0 pts
Insufficient
Didn’t answer question, or
answer is extremely wrong.
|
1 pts
|
|
part2.py: Outputs correct vaccination percentage for
country
|
2 pts
Correct answer
Program has correct
answer using sensible
Python code
|
1 pts
Incorrect answer
Output format incorrect
using sensible Python
code
|
0 pts
Insufficient
Didn’t answer question,
or answer is extremely
wrong.
|
2 pts
|
part2.py: Outputs correct worldwide average
|
2 pts
Correct answer
Program has correct
answer using sensible
Python code
|
1 pts
Incorrect answer
Output format incorrect
using sensible Python
code
|
0 pts
Insufficient
Didn’t answer question,
or answer is extremely
wrong.
|
2 pts
|
part2.py: Outputs correct country with lowest
percentage
|
2 pts
Correct answer
Program has correct
answer using sensible
Python code
|
1 pts
Incorrect answer
Output format incorrect
using sensible Python
code
|
0 pts
Insufficient
Didn’t answer question,
or answer is extremely
wrong.
|
2 pts
|
part2.py: Outputs correct country with highest
percentage
|
2 pts
Correct answer
Program has correct
answer using sensible
Python code
|
1 pts
Incorrect answer
Output format incorrect
using sensible Python
code
|
0 pts
Insufficient
Didn’t answer question,
or answer is extremely
wrong.
|
2 pts
|
Style: Well named variable names and header
|
2 pts
Submitted i
|
0 pts
Not as requested
|
2 pts
|
|
Total Points: 20 |