Permalink
Browse files

Step 5 - Isolate the average salary algorithm

  • Loading branch information...
lgiordani committed Jul 15, 2017
1 parent 9db1803 commit 412220145ea4d7ef846b1d1f289b4ddefc4fb24b
Showing with 11 additions and 2 deletions.
  1. +4 −2 datastats/datastats.py
  2. +7 −0 tests/test_datastats.py
View
@@ -4,6 +4,9 @@
class DataStats:
def _avg_salary(self, data):
return math.floor(sum([int(e['salary'][1:]) for e in data])/len(data))
def _avg_age(self, data):
return math.floor(sum([e['age'] for e in data])/len(data))
@@ -33,8 +36,7 @@ def _stats(self, data, iage, isalary):
return {
'avg_age': self._avg_age(data),
'avg_salary': math.floor(sum(
[int(e['salary'][1:]) for e in data])/len(data)),
'avg_salary': self._avg_salary(data),
'avg_yearly_increase': yearly_avg_increase,
'max_salary': max_salary,
'min_salary': min_salary
View
@@ -85,3 +85,10 @@ def test__avg_age():
ds = DataStats()
assert ds._avg_age(test_data) == 62
def test__avg_salary():
ds = DataStats()
assert ds._avg_salary(test_data) == 55165

0 comments on commit 4122201

Please sign in to comment.