Learning Outcomes By completing this assignment, you will demonstrate the ability to: • create and use dictionaries, lis

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Learning Outcomes By completing this assignment, you will demonstrate the ability to: • create and use dictionaries, lis

Post by answerhappygod »

Learning Outcomes By Completing This Assignment You Will Demonstrate The Ability To Create And Use Dictionaries Lis 1
Learning Outcomes By Completing This Assignment You Will Demonstrate The Ability To Create And Use Dictionaries Lis 1 (60.35 KiB) Viewed 18 times
Learning Outcomes By Completing This Assignment You Will Demonstrate The Ability To Create And Use Dictionaries Lis 2
Learning Outcomes By Completing This Assignment You Will Demonstrate The Ability To Create And Use Dictionaries Lis 2 (76.55 KiB) Viewed 18 times
Learning Outcomes By Completing This Assignment You Will Demonstrate The Ability To Create And Use Dictionaries Lis 3
Learning Outcomes By Completing This Assignment You Will Demonstrate The Ability To Create And Use Dictionaries Lis 3 (74.09 KiB) Viewed 18 times
Learning Outcomes By Completing This Assignment You Will Demonstrate The Ability To Create And Use Dictionaries Lis 4
Learning Outcomes By Completing This Assignment You Will Demonstrate The Ability To Create And Use Dictionaries Lis 4 (60.3 KiB) Viewed 18 times
Learning Outcomes By Completing This Assignment You Will Demonstrate The Ability To Create And Use Dictionaries Lis 5
Learning Outcomes By Completing This Assignment You Will Demonstrate The Ability To Create And Use Dictionaries Lis 5 (65.37 KiB) Viewed 18 times
Learning Outcomes By completing this assignment, you will demonstrate the ability to: • create and use dictionaries, lists, and tuples; ● do some simple data analysis; • extract data from a file; ● output data to a file. Task This assignment will focus on applying your knowledge of programming and data structures to a real-world dataset. You will be looking at Covid data from the Middlesex-London Health Unit (MLHU), building data structures using that data and then building functions to extract some information from that data. The pre-processing of the files has been (mostly) handled for you so that you can focus on importing and analyzing the data. You will need to be comfortable with all the materials up to the end of Lecture #8 to complete this assignment, and you will likely find Chapter 8 of zyBooks (and its associated labs) useful.

Functional Requirements/Specifications You need to create two program files: • doses.py; • analyze_doses.py. Each of these files will write to another file: • doses.py writes to doses.csv; • analyze_doses.py writes to vaccine_stats.txt. All of the above files are described in detail below. A General Note on Reading Files When you need to read .csv files into your program, you will use the csv module. Documentation can be found here: https://docs.python.org/3/library/csv.html. This module is made use of in section 8.7 of zyBooks and in the labs for Chapter 8 of zyBooks. You can use the reader method from the csv module to read the file into your program. It may take some playing around with to get the data structures working properly. You will likely want to use quite a few print() statements for debugging while you work. The doses.py File I This file will contain two functions: • Function Name: main() This function prompts the user to enter a .csv file to read (e.g.. doses_data_mar_30.csv). This file contains vaccination information. The function should read the file's contents into a dictionary of lists. Each list in the dictionary contains the doses given at each location on a given date. The dictionary keys should be the dates on which the doses were administered, and the value should be the list of doses by location. Example: (2020-12-20': ['e', 'e', 'e', 'e', '206'], 2020- 12-27 ['0', 'e', 'e', 'e', '1,799'], 2021-01-03': ['0',

'e', 'e', 'e', '3,787'], 2021-01-10': ['198', 'e', '0', 'e', '3,875']... Be careful: the data may contain multiple entries for some of the dates, so you'll have to check to see if a key already exists before storing information. You also must consider that some numbers are stored as strings, while others are stored as integers and handle this. Hints: 1. setdefault(string, []) can help create the basic dictionary structure. This sets the default key as a string, and the default value as a list. 2. You can use the following line of code to skip the column headers before writing to the dictionary, as the column headers will break your dictionary: next(reader, None). The main() function processes data and then outputs that data to doses.csv. This function adds up the number of vaccine doses administered at different locations on each date. You will need to do some minor processing of strings here to count them, as the file has numbers that contain commas and entries with empty values. Hint: remove the commas from the numbers and replace the empty values with zeroes. o Parameter: a list containing the dose number for each location on a given date. o Return Value: a total vaccination count for that date. This file will output a file named doses.csv, which will contain entries that look like this: 2020-12-20, 06 2020-12-27, 1799 2021-01-03, 3787 2021-01-10, 4073 moet • Function Name: count_doses_by_date()

The first value is the date (technically, it's the first day of the week from which the vaccination numbers were taken), and the second value is the total vaccination count for that date (an integer). For the doses_data_mar_20.csv file, your output file should contain 66 entries, and, depending on how you write your output, it may have a 67th entry that is just an empty line). The result of running the program will look like this: which data would like to consider? Date: 2020-12-20 Doses: ['0', '0', '0', '0', '206'1 Date: 2020-12-27 Doses: ['0', 0, 0, 0, 1,799] Date: 2021-81-03 Doses: ['0', '0', 0, '8', '3,787") Date: 2021-01-18 Doses: ['198', 0, 0, 0, 3,875 1 Date: 2021-01-17 Doses: ['2,098, 47', '8', '8', '1,588] Date: 2021-81-24 Doses: ['645', 0, 0, 0, '127"] Date: 2021-01-31 Doses: [918', '54', '0', Date: 2021-02-07 Doses: ['1,954, 42, 8, 8, 2,548) Date: 2021-02-14 Doses: [917, 0, 0, 0, '5,042¹] Date: 2021-02-21 Doses: [3,232, 6, 8, 5,70 Date: 2021-02-28 Doses: [156, 938, 8, 6, 7,517"] The analyze_doses.py File This file will contain (at least) four functions: Function Name: main() This function reads the doses.csv file you created with your doses.py file. It should store that data in a list of tuples. Example: [('2020-12-20¹, 206), ('2020-12-27', 1799), ('2021- 01-03, 3787)

The function processes data and then outputs that data to vaccine_stats.txt. This function identifies the date with the fewest vaccinations. o Parameter: the list containing the number of vaccinations by date. o Return Value: a tuple containing the date of the fewest vaccinations and the total number of vaccinations that took place on that date. • Function Name: minimum() • Function Name: maximum() This function identifies the date with the most vaccinations. o Parameter: the list containing the number of vaccinations by date. o Return Value: a tuple containing the date of the most vaccinations and the total number of vaccinations that took place on that date. • Function Name: total_vaccinations() This function adds up the number of vaccine doses delivered by different locations on the same date to get a total number of vaccinations. o Parameter: the list containing the number of vaccinations by date. o Return Value: an integer containing the total number of vaccinations that took place. You may also include any helper functions you wish to include. Remember that the aim is to generalize your code wherever possible so that you aren't repeating the same code over and over again. If you find that you are repeating sections of code, see if you can encapsulate that code in a generalized way. This file will output a file named vaccine_stats.txt, which should look exactly like this: Total doses: 1116678 Minimum date: 2020-12-20, Doses: 206 Maximum date: 2021-06-27, Doses: 56999
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply