1
answer
0
watching
414
views


Covid_Data = [["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]]]]

le 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 rst item in Covid_Data
is a list whose rst 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 rst 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 rst
item is the number of people fully vaccinated and the second item is the population of that province in the
givien age group.
Just copy/paste this list of lists to your program. But keep in mind that your code should work even if we
use a dierent starting list (representing a dierent 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 rst 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 nd 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
rst parameter, the lower and upper bounds of an age range as its other two parameters. This function rst
prints out a line indicating the age range, then it should call the function prov_percent_vaccinated_in_age_range
and for each province represented in the data prints out a line indicating the percent fully vaccinated in
that province.

For example: Write a function called add_vaccinated_in_age_bracket that takes the list of lists (described above) as its
rst parameter and modies 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 nal 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 2


For unlimited access to Homework Help, a Homework+ subscription is required.

Avatar image
Read by 6 people

Unlock all answers

Get 1 free homework help answer.
Already have an account? Log in

Related questions

Related Documents

Weekly leaderboard

Start filling in the gaps now
Log in