Question: Python programming def sort_by_last_name(list_of_employees): Question 8 - Jim is upset that Dwight is getting a higher raise than him so he decides to change
Python programming
def sort_by_last_name(list_of_employees): """ Question 8 - Jim is upset that Dwight is getting a higher raise than him so he decides to change the order. He decides to re-sort them by last name in ascending order so that he will earn more than Dwight. He doesn't want anyone to know he changed the order though, so sort the list in place (but return None). >>> emps = [ ("Kelly Kapoor", 32), ("Pam Beesly", 30), ("Jim Halpert", 36), \ ("Creed Bratton", 73), ("Dwight Schrute", 38) ] >>> sort_by_last_name(emps) >>> emps [('Pam Beesly', 30), ('Creed Bratton', 73), ('Jim Halpert', 36), ('Kelly Kapoor', 32), \ ('Dwight Schrute', 38)] """ pass
def swap_ages(names, ages): """ Question 9 - In retaliation, Dwight decides to prank Jim (and everyone else) by swapping the ages of everyone in the office in the office information booklet. He does this by matching the first name with the last age, the second name to the second-to-last age, and so on. Return a dictionary mapping the employee's names to their swapped ages. Hint: This can be done in a dictionary comprehension! >>> names = [("Kelly", "Kapoor"), ("Pam", "Beesly"), ("Jim", "Halpert"), ("Creed", "Bratton"), \ ("Dwight", "Schrute")] >>> ages = [32, 30, 36, 73, 38] >>> swap_ages(names, ages) 'Kelly Kapoor': 38, 'Pam Beesly': 73, 'Jim Halpert': 36, 'Creed Bratton': 30, 'Dwight Schrute': 32} """ pass
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
