A 72-yeаr-оld is in respirаtоry fаilure as a cоmplication of COPD. His PaCO2 is 65 mm Hg and he is somnolent and restless. Which intervention does the nurse implement to improve oxygenation and prevent increasing hypercapnia?
Uplоаd а Pythоn sоurce file (.py) thаt defines a function named transform. This function will take a list of dictionaries as its only parameter. This list contains dictionaries that each hold information about an ebay auction. The function will then return a single dictionary that will contain the same information but differently structured, as explained below. Let us start by putting the following code in your global scope: data = [ { 'name' : 'Atari Falcon 030', 'starting_price' : '499.99' }, { 'name' : 'Raspberry PI 400', 'starting_price' : '50.45' }, { 'name' : 'Lenovo T480', 'starting_price' : '200.59' }, { 'name' : 'Clockworks DevTerm', 'starting_price' : '259.95' }, { 'name' : 'HP DevOne', 'starting_price' : '759.85' } ] As you can see, the dictionaries in our list contain both the name of the items being listed (a string value corresponding to the key 'name' in that item's dictionary) and the starting price of the item (a string value corresponding to the key 'starting_price' in that item's dictionary). We want our function to return a dictionary in which the keys are the names of the items (we'll assume they are always unique) and the values are their respective starting price, as a float. With the example above, calling our function on the data variable would return a dictionary structured as follows: { 'Atari Falcon 030' : 499.99 , 'Raspberry PI 400' : 50.45 , 'Lenovo T480' : 200.59 , 'Clockworks DevTerm' : 259.95 , 'HP DevOne' : 789.85} You are free to add more code to the global scope of your file in order to call your function to test it. This extra code will not be graded but will help you ensure that your function performs as expected. Grading Rubric: The function creates an empty dictionary named result to start off with (1 point) The function iterates over the list correctly (1 point) The function correctly adds the content from each of the dictionaries in the list parameter, to the result dictionary (1 point) The function returns the correct result dictionary corresponding to the contents of the list passed as argument (1 point)
Cоnsider the fоllоwing dаtа structure: bookshelf = [ { 'title' : 'The Colour of Mаgic', 'author': 'terry pratchett', 'rating': 9, 'number_of_pages': 268 }, { 'title' : 'Dragonriders of Pern', 'author': 'anne mccaffrey', 'rating':8, 'number_of_pages': 256 }, { 'title' : 'The Hogfather', 'author': 'terry pratchett', 'rating': 10, 'number_of_pages': 404 }, {'title' : 'All the Weyrs of Pern', 'author': 'anne mccaffrey', 'rating': 7, 'number_of_pages': 312 }, { 'title' : 'Going Postal', 'author': 'terry pratchett', 'rating': 8, 'number_of_pages': 372 } ] Write a function named compute_stats that takes as first argument a list of dictionaries similar to the above, and a string representing the name of an author as second argument. It will return a tuple of two values: the first one will be the average rating (as a float) based on all books by that author found in the list. The second one will be the total number of pages of all books by that author found in the list. If the author passed as argument is not found in the books recorded in our list of dictionaries, then your function will return a tuple containing None and None. Please note that the author passed as argument may be spelled with a mixture of upper and lower cases and may have extraneous spaces at the beginning or end of the string. compute_stats(books, author_name) # returns a tuple containing: # the average rating (as a float) for all the books by that author # the total number of pages (as an int) for all the books by that author Grading Rubric: Iterates correctly over all books in the first parameter (1 point) Computes and return the average rating correctly (1 point) Computes and return the average rating correctly (1 point) Returns the two values as a tuple (1 point) Returns (None, None) when the author is not found (1 point) In the global scope, you call that function, then assign its two return values to two separate variables without having to use indexing (1 point)