Created
August 18, 2020 16:21
-
-
Save FBosler/486e4d7e91c89a9428e091de9e05e59c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IN: | |
employees = [ | |
{ | |
"name": "John Don't", | |
"performance": "medium", | |
"salary": 10000 | |
}, | |
{ | |
"name": "Jane Does", | |
"performance": "high", | |
"salary": 9000 | |
} | |
] | |
def adjust_salary(employee): | |
brackets = { | |
"high": 1.2, | |
"medium": 1.03, | |
"low": 1 | |
} | |
factor = brackets[employee["performance"]] | |
current_salary = employee["salary"] | |
return { | |
"name" : employee["name"], | |
"performance": employee["performance"], | |
"salary": current_salary * factor | |
} | |
[adjust_salary(employee) for employee in employees] | |
OUT: | |
[ | |
{ | |
"name":"John Don't", | |
"performance":"medium", | |
"salary":10300.0 | |
}, | |
{ | |
"name":"Jane Does", | |
"performance":"high", | |
"salary":10800.0 | |
} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment