Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please use Python a5q3v1_starter.py is a file that contains a list of lists, to which the variable Covid_Data refers, which contains information about vaccination numbers,

Please use Python

image text in transcribedimage text in transcribedimage text in transcribed

a5q3v1_starter.py is a file that contains a list of lists, to which the variable Covid_Data refers, which contains information about vaccination numbers, by age bracket, in some provinces. 1 The first item in Covid_Data is a list whose first item is a string "age bracket" , and whose second item is a list of the names of several provinces. The other items in Covid_Data are lists whose first item is a tuple denoting an age bracket and whose second item is a list of lists. Each of these sublists correspond to data from a province and the first item is the number of people fully vaccinated and the second item is the population of that province in the givien age group. You should work directly on the starter file a5q3v1_starter.py. Keep in mind that your code should work even if we use a different starting list (representing a different set of provinces, though with the same format) to test your program. Determine percentage of people fully vaccinated in an age range for each given province. To do this you will need to write a function called prov_percent_vaccinated_in_age_range, which takes the list of lists described above as the first parameter, and the name of a particular province. given as a string (ie. "BC"), as the second parameter, the lower and upper bounds on an age range are the third and fourth parameters. This function should return the percent fully vaccinated in the given age range in the given province. To do this you may find the list method .index () useful to determine the index of of the data corresponding to a province. Note that L. index("Prov") will be 2 if "Prov" is the 3th item in list L. For example, in the sample data, the index of "SK" in the list Covid_Data [0] [1] is 2. To limit the number of decimal places returned use the function round(). For example. If x=3.567, then round (x,1) returns 3.6. Next create a function percent_vaccinated_in_age_range which takes the list of lists described above as its first parameter, the lower and upper bounds of an age range as its other two parameters. This function first prints out a line indicating the age range, then it should call the function prov_percent_vaccinated_in_age_rat and for each province represented in the data prints out a line indicating the percent fully vaccinated in that province. For example: In the main program call the function percent_vaccinated_in_age_range twice. first with the age range from 30 to 49 , and second for the age range 12 to 29 . Write a function called add_vaccinated_in_age_bracket that takes the list of lists (described above) as its first parameter and modifies it. The second parameter is the name of a province given as a string, the third parameter is an age bracket ( given as a tuple), and the final parameter is a number to add to the number of fully vaccinated people in the given age bracket for the given province. This change should be done by modifying the input list itself. No new lists should be created and this function has no return value. Assume that recently, in "SK", there has been a vaccination blitz in high schools. This has added 10000 to the number of fully vaccinated in the age bracket from 12 to 17. Print "-- After High School Vaccination Blitz --". In the main program, call the function add_vaccinated_in_age_bracket to record the results of this vaccination blitz. Finally call percent_vaccinated_in_age_range again for the age range 12 to 29. \( \begin{array}{l} \text { \# Covid Data Analysis } \\ \text { Covid_Data }= {[[\text { "age bracket", ["BC", "AB", "SK" }]], } \\ {[(12,17),[[212286,303122],[200521,315968],[51128,87621]]], } \\ {[(18,29),[[576245,816781],[412013,695111],[100170,181751]]] } \\ {[(30,39),[[561039,740505],[459399,715542],[106941,172421]]] } \\ {[(40,49),[[514551,649358],[437833,608434],[102214,143466]]] } \\ \text { print("--- After High School Vaccination Blitz ---") }\end{array} \)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Accidental Data Scientist

Authors: Amy Affelt

1st Edition

1573877077, 9781573877077

More Books

Students also viewed these Databases questions