Skip to content

Instantly share code, notes, and snippets.

@FBosler
Created August 18, 2020 16:21
Show Gist options
  • Save FBosler/486e4d7e91c89a9428e091de9e05e59c to your computer and use it in GitHub Desktop.
Save FBosler/486e4d7e91c89a9428e091de9e05e59c to your computer and use it in GitHub Desktop.
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