Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
vars(self).update(locals()) solution in Clear category for Every Person is Unique by flpo
from datetime import datetime as dt
class Person:
def __init__(self, first_name, last_name, birth_date, job, working_years, salary, country, city, gender='unknown'):
vars(self).update(locals())
def name(self):
return f'{self.first_name} {self.last_name}'
def age(self):
return (dt(2018,1,1) - dt.strptime(self.birth_date, '%d.%m.%Y')).days // 365.2425
def work(self):
genders = {'male': 'He is', 'female': 'She is', 'unknown': 'Is'}
return f'{genders[self.gender]} a {self.job}'
def money(self):
return f'{12 * self.working_years * self.salary:,}'.replace(',', ' ')
def home(self):
return f'Lives in {self.city}, {self.country}'
June 5, 2018
Comments: