Question: Question # 7 : employee _ update ( d , bonus, year ) 1 0 ptsModifies the given dictionary d by adding another key:value assignment
Question #: employeeupdated bonus, year ptsModifies the given dictionary d by adding another key:value assignment for all employees butwith a bonus for the next year. You can assume the previous year exists in the dictionary.Preconditions and Postconditionsd: dictbonus: intfloatyear: intReturns: dict adds the key:value pair with bonus appliedRecommended methods: dict.keys returns all the keys in a dictionaryo D one: 'two': 'three': 'four':o Dkeys returns one 'two', 'three', 'four' List concatenation or append methodTip: Dictionaries, just like lists, are mutable, so saving a reference to a dictionary, say xdmapping x to another key in d and then changing information in x will also change the data ind which is not a desirable behavior. When adding a new key, create new dictionaries andlists and populate them with the required data.Examples: records :John:Managing Director","Fulltime","Sally":HR Director","Fulltime","Max":Sales Associate","Parttime",:John:Managing Director","Fulltime","Sally":HR Director","Fulltime","Max":Sales Associate","Parttime", employeeupdaterecords: John: Managing Director', 'Fulltime', 'Sally': HR Director', 'Fulltime', 'Max': Sales Associate', 'Parttime', : John: Managing Director', 'Fulltime', 'Sally': HR Director', 'Fulltime', 'Max': Sales Associate', 'Parttime', : John: Managing Director', 'Fulltime', 'Sally': HR Director', 'Fulltime', 'Max': Sales Associate', 'Parttime', Question #: overloadedaddd key, value ptsGiven a dictionary d a key, and a value, this function adds the key:value pair to the dictionary dIf the key doesnt already exist in the dictionary, this function should simply add it However, ifthe key already exists, then rather than overriding the previous value, the dictionary should startkeeping a list of values for that key, in the order they are added.Preconditions and Postconditionsd: dict You cannot make any assumptions about the size or contents of dkey: any immutable typevalue: anyReturns: None
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
