Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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)

image text in transcribedimage text in transcribedimage text in transcribed
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>

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

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

give some examol id

Answered: 1 week ago

Question

Where would you see the nodes of ranvier ?

Answered: 1 week ago

Question

Damage to the hippocampus is the most likely to impair ?

Answered: 1 week ago

Question

The terminal buttons of a neuron are located at the end of its ?

Answered: 1 week ago

Question

The effect of neurotransmitters may be..........?

Answered: 1 week ago

Question

Where was the declaration of independence signed?

Answered: 1 week ago