Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using concepts which you were specifically told not to use Use of global variables, break or continue statements in loops ( while these statements are

Using concepts which you were specifically told not to use
Use of global variables, break or continue statements in loops (while these statements are useful to provide multiple exit points in loops, they are highly abused when starting to program instead of defining a meaningful continuation condition. None of the problems in this course involve complex exit points, hence, their use is prohibited in all components of this course)
Question #7: employee_update(d, bonus, year)
Modifies the given dictionary d by adding another key:value assignment for all employees but
with a bonus for the next year. You can assume the previous year exists in the dictionary.
Preconditions and Postconditions
d : dict
bonus: int/float
year: int
Returns: dict adds the key:value pair with bonus applied
Recommended methods:
dict.keys(), returns all the keys in a dictionary
'one': 1, 'two': 2, 'three': 3, 'four':4})
D.keys() returns ['one', 'two', 'three', 'four']
List concatenation (+) or append method
Tip: Dictionaries, just like lists, are mutable, so saving a reference to a dictionary, say ],
mapping x to another key in d and then changing information in x, will also change the data in
d[2020], which is not a desirable behavior. When adding a new key, create new dictionaries and
lists and populate them with the required data.
Examples:
records
2020:{"John": ["Managing Director", "Full-time", 65000], "Sally":["HR Director", "Full-
time", 60000], "Max": ["Sales Associate", "Part-time", 20000]},
2021:{"John": ["Managing Director", "Full-time", 70000], "Sally":["HR Director", "Full-
time",65000], "Max": ["Sales Associate", "Part-time", 25000]}}
> employee_update(records,7500,2022)
{2020: {'John': ['Managing Director', 'Full-time', 65000], 'Sally': ['HR Director', 'Full-
time', 60000], 'Max': ['Sales Associate', 'Part-time', 20000]},
2021: {'John': ['Managing Director', 'Full-time', 70000], 'Sally': ['HR Director', 'Full-
time', 65000], 'Max': ['Sales Associate', 'Part-time', 25000]},
2022: {'John': ['Managing Director', 'Full-time', 77500], 'Sally': ['HR Director', 'Full-
time', 72500], 'Max': ['Sales Associate', 'Part-time', 32500]}}
image text in transcribed

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

Database Processing Fundamentals Design And Implementation

Authors: David M. Kroenke

5th Edition

B000CSIH5A, 978-0023668814

More Books

Students also viewed these Databases questions