Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Given this xml file, please help me complete the following: The root element is

ID: 664784 • Letter: G

Question

Given this xml file, please help me complete the following:

The root element is CATALOG and contains a series of BOOK elements, each of which represents a single BOOK. Each BOOK element has a number of child elements such as AUTHOR, TITLE, GENRE, PRICE and so on.

Write a function called book_info that prints the title, author, and price of the book with a certain id (passed as a parameter). Build a list of all book ids in the XML file and call this function on each of them. Example call: book_info(“bk111”)

Print the total cost of buying all the books in the “Computer” genre.
Print the unique genres in the file.
Use list comprehensions to minimize the code required in parts a – b.
Use list comprehensions AND dictionary comprehensions to minimize the code required in part c.

Should be in python, with appropriately named variables and using list comprehensions to minimize the code.

Link to the xml file:

https://drive.google.com/file/d/0B5FX84Uyz9fjR0p4aUpkaUJaaFE/view?usp=sharing

Explanation / Answer

from xml.etree import ElementTree with open('test.xml', 'rt') as f: tree = ElementTree.parse(f) for node in tree.iter('book'): bookid = node.attrib.get('id') author = node.findnext('author') title = node.findnext('title') genre = node.findnext('genre') price = node.findnext('price') publish_date = node.findtext('publish_date') description = node.findtext('description')

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote