Question

In PythonQuestion 3 (13 points): Purpose: To practice your ability to modify lists and compute with lists of lists Degree of DifficultThese changes should be done by modifying the input list itself. No new lists should be created and this function has no retu#Population Analysis # for each row [age group, BC, AB, SK, MB] Pop_data = [[age group [BC,AB,SK, MB]], [0 to 4 ye

0 0
Add a comment Improve this question Transcribed image text
Answer #1
Pop_data = [["age group",["BC","AB","SK","MB"]],

["0 to 4 years",[225897,269163,75200,85220]],

["5 to 9 years",[244206,277785,78696,89507]],

["18 to 14 years",[249173,276328,76730,86583]],

["15 to 19 years",[272195,256742,71304,85808]],

[ "20 to 24 years",[340325,277328,75402,96636]],

["25 to 29 years",[358457,314507,77488, 97157]],

["30 to 34 years",[376466,356226,85751,98789]],

["35 to 39 years",[363871, 359301,86664,95203]],

[ "40 to 44 years",[323620,319889,76067,86739]],

[ "45 to 49 years", [325674,288546,67397 ,82541]],

["50 to 54 years",[343894, 266489, 65716,80302]],

["55 to 59 years",[376848,284259,77024, 89949]],

["60 ta 64 years", [360150,264339, 74222, 83163]],

["65 to 69 years",[314021,210073, 62071,70981]],

["70 to 74 years",[262197,157657, 46528,57001]],

["75 to 79 years" ,[174377, 102977, 31910,38329]],

["80 to 84 years",[115218,68565,22791,25922]],

[" 85 to 89 years",[73205,44033 ,15931 ,16952]],
["90 to 94 years ", [35355,20921,8492,8968]],

["95 to 99 years",[10613,5746,2773,3010]],

["100 years and over",[1950,1002,524,503]]]


#function for calculating totsl population os province
def prov_total(prov_index):
  population=0
  for j in range(1,len(Pop_data)):
    population+=Pop_data[j][1][prov_index]
  return population

#for calculating population of senior citizens in a province
def senior_total(prov_index):
  senior_population=0
  for k in range(14,len(Pop_data)):
    senior_population+=Pop_data[k][1][prov_index]
  return senior_population

#for calculating percentage of sneior citizens in a Province
def senior_percentage(population,senior_population):
  return (senior_population/population)*100

#for printing the percentage of senior citizens of all province
def all_senior_percentage(Pop_data):
  for i in Pop_data[0][1]:
    prov=i;
    prov_index=Pop_data[0][1].index(prov)
    prov_population=prov_total(prov_index)
    prov_senior=senior_total(prov_index)
    sen_percentage=senior_percentage(prov_population,prov_senior)
    print("Total population of ",prov," is ",prov_population," and the percentage of seniors in ",prov," is ",round(sen_percentage,2))

#for creating the Buffalo province by updating the list
def create_buffalo(Pop_data):
  print("The province of Buffalo has been created")
  index1=prov_index=Pop_data[0][1].index("AB")
  index2=prov_index=Pop_data[0][1].index("SK")
  Pop_data[0][1][1]="Buffalo"
  Pop_data[0][1][2]=Pop_data[0][1][3]
  del Pop_data[0][1][3]
  for l in range(1,len(Pop_data)):
    Pop_data[l][1][1]=Pop_data[l][1][1]+Pop_data[l][1][2]
    Pop_data[l][1][2]=Pop_data[l][1][3]
    del Pop_data[l][1][3]
  for m in range(3):
    print(Pop_data[m])

#calling of all functions
all_senior_percentage(Pop_data)
create_buffalo(Pop_data)
all_senior_percentage(Pop_data)

OUTPUT:

.Total population of BC is 5147712 and the percentage of seniors in BC is 19.17 Total population of AB is 4421876 and the perc

Add a comment
Know the answer?
Add Answer to:
In Python Question 3 (13 points): Purpose: To practice your ability to modify lists and compute...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • using this code to complete. it python 3.#Display Program Purpose print("The program will show how much...

    using this code to complete. it python 3.#Display Program Purpose print("The program will show how much money you will make working a job that gives a inputted percentage increase each year") #Declaration and Initialization of Variables userName = "" #Variable to hold user's name currentYear = 0 #Variable to hold current year input birthYear = 0 #Variable to hold birth year input startingSalary = 0 #Variable to hold starting salary input retirementAge = 0 #Variable to hold retirement age input...

  • Pseudocode & Python In this portion of the project you will analyze a problem and create...

    Pseudocode & Python In this portion of the project you will analyze a problem and create a Python program to solve it. In recent years, there has been more attention to Water Quality. Specifically the amount of lead that is found in our daily water supply. Lead and copper residue start to show up in our water supply due to aging pipes. This residue can be found in older homes that have not replaced their pipes and in the municipal...

  • Which of the following is an advantage of technology in nursing practice? a. inclination of nurses...

    Which of the following is an advantage of technology in nursing practice? a. inclination of nurses to focus on the equipment rather than the patient b. increased ability to monitor patients remotely c. increased confidentiality of patient information d. reliability of internet resources 2. When using computers in direct patient care, it is important to remember to: a. assess the patient and provide care based on the individual's needs b. look up the clinical practice guidelines for each illness use...

  • Please read the article bellow and discuss the shift in the company's approach to genetic analysis....

    Please read the article bellow and discuss the shift in the company's approach to genetic analysis. Please also discuss what you think about personal genomic companies' approaches to research. Feel free to compare 23andMe's polices on research with another company's. Did you think the FDA was right in prohibiting 23andMe from providing health information? These are some sample talking points to get you thinking about the ethics of genetic research in the context of Big Data. You don't have to...

  • SYNOPSIS The product manager for coffee development at Kraft Canada must decide whether to introduce the...

    SYNOPSIS The product manager for coffee development at Kraft Canada must decide whether to introduce the company's new line of single-serve coffee pods or to await results from the product's launch in the United States. Key strategic decisions include choosing the target market to focus on and determining the value proposition to emphasize. Important questions are also raised in regard to how the new product should be branded, the flavors to offer, whether Kraft should use traditional distribution channels or...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT