Question: make python script to process the data in the XML. The file name is leading_causes_of_death.xml At the first of the file (after any import statements)

  1. make python script to process the data in the XML.The file name is leading_causes_of_death.xml
  2. At the first of the file (after any import statements) define three functions
  • main()
  • process_row(row)
  • print_rows(row_list)
  1. In themainfunction:
  • Ask the user to input a year ("Please enter a year: ")
  • An empty list variable calledcod_listshould be initialized
  • Aforloop should be used to move through therowelements of the xml file.
  • Each row in the xml file should be passed to theprocess_rowfunction. Theprocess_rowfunction should return a dictionary. Each dictionary should then be appended to thecod_list
  • After theforloop thecod_listshould be passed to theprint_rowsfunction
  • Also pass the inputted year as a parameter to the print_rows function
  1. In theprint_rowsfunction
  • A for loop to move through each dictionary using the enumerate function to keep track of the index
  • If the year matches the user inputted year, print out the record index, the id of the row, and the informational text that follows this pattern:
  • Record 2 (id: 15031): During 2016 the leading cause of death in Arizona was Unintentional Injuries
  1. Within theprocess_rowsfunction:
  2. Every element in a row should become a key-value pair (example: 'year', 'state', and 'deaths' are all examples of keys and the associated text would be their values within the dictionary)
  3. Also, each dictionary item should also include a key-value pair specifying the id of the row.
  4. Code minimalism requirements:
  5. You should use the if __name__=='__main__':syntax to call your main method
  6. Do not use global variables. If a function needs a variable then pass it as a parameter.
  7. The only code at the far left indent should be functions, import statements, and the if statement that calls the main function
  8. Do not use inner functions (a function within a function)

make python script to process the data in the XML.The file nameis leading_causes_of_death.xmlAt the first of the file (after any import statements) definethree functionsmain()process_row(row)print_rows(row_list)In themainfunction:Ask the user to input a year ("Please enter a
2016 <_113_cause_name>Accidents (unintentional injuries) (V01-X59,Y85-Y86) 113_cause_name> Unintentional injuries Alabama 2755 55.5 2016 <_113_cause_name>Accidents (unintentional injuries) (V01-X59,Y85-Y86) 113_cause_name> Unintentional injuries Alaska 439 63.1 2016 <_113_cause_name>Accidents (unintentional injuries) (V01-X59,Y85-Y86) 113_cause_name> Unintentional injuries Arizona 4010 54.2 2016 <_113_cause_name>Accidents (unintentional injuries) (V01-X59,Y85-Y86) 113_cause_name> Unintentional injuries Arkansas 1604 51.8 2016 <_113_cause_name>Accidents (unintentional injuries) (V01-X59,Y85-Y86) Unintentional injuries California 13213 32 2016 <_113_cause_name>Accidents (unintentional injuries) (V01-X59,Y85-Y86) _113_cause_name> Unintentional injuries Colorado 2880 51.2 2016 <_113_cause_name>Accidents (unintentional injuries) (V01-X59,Y85-Y86) 113_cause_name> Unintentional injuries Connecticut 1978 50.3 2016 <_113_cause_name>Accidents (unintentional injuries) (V01-X59,Y85-Y86) 113_cause_name> Unintentional injuries Delaware 516 52.4 2016 <_113_cause_name>Accidents (unintentional injuries) (V01-X59,Y85-Y86) _113_cause_name> Unintentional injuries District of Columbia 401 58.3 2016 <_113_cause_name>Accidents (unintentional injuries) (V01-X59,Y85-Y86) 113_cause_name> Unintentional injuries Florida 12561 54.9 '> 2016 <_113_cause_name>Accidents (unintentional injuries) (V01-X59,Y85-Y86) 113_cause_name> Unintentional injuries Georgia 4701 45.8 2016 <_113_cause_name>Accidents (unintentional injuries) (V01-X59,Y85-Y86) 113_cause_name> Unintentional injuries Hawaii 577 35.3 2016 <_113_cause_name>Accidents (unintentional injuries) (V01-X59,Y85-Y86) 113_cause_name'> Unintentional injuries Idaho 849 49.5 '> 2016 <_113_cause_name>Accidents (unintentional injuries) (V01-X59,Y85-Y86) 113_cause_name> Unintentional injuries&gt

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!