Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Every Person is Unique by mozurin
import functools
import math
class Person:
def __init__(
self,
first_name,
last_name,
birth_date,
job,
working_years,
salary,
country,
city,
gender='unknown'
):
for k, v in locals().items():
setattr(self, k, v)
def name(self):
return f'{self.first_name} {self.last_name}'
def age(self):
return math.floor(
functools.reduce(
lambda s, x: s - x,
map(
lambda date: functools.reduce(
lambda s, x: s / 100 + x,
map(int, date.split('.'))
),
('01.01.2018', self.birth_date, )
)
)
)
def work(self):
return (
{
'male': 'He is',
'female': 'She is',
'unknown': 'Is',
}[self.gender]
) + f' a {self.job}'
def money(self):
return '{:,}'.format(
self.working_years * self.salary * 12
).replace(',', ' ')
def home(self):
return f'Lives in {self.city}, {self.country}'
June 30, 2018
Comments: