Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
map int split solution in Clear category for Every Person is Unique by ogoro
NOW = '01.01.2018'
WORK_PREFIXES = {'female': 'She is a', 'male': 'He is a', 'other': 'Is a'}
class Person:
def __init__(self, first_name, last_name, birth_date, job, working_years, salary, country, city, gender='other'):
self.first_name = first_name
self.last_name = last_name
self.birth_date = birth_date
self.job = job
self.working_years = working_years
self.salary = salary
self.country = country
self.city = city
self.gender = gender
def name(self):
return f'{self.first_name} {self.last_name}'
def age(self):
now_day, now_month, now_year = map(int, NOW.split('.'))
birth_day, birth_month, birth_year = map(int, self.birth_date.split('.'))
stuffed_day = birth_month > now_month and birth_day > now_day
year_delta = now_year - birth_year - stuffed_day
return year_delta
def work(self):
return WORK_PREFIXES[self.gender] + ' ' + self.job
def money(self):
return f'{self.salary * self.working_years * 12:,}'.replace(',', ' ')
def home(self):
return f'Lives in {self.city}, {self.country}'
March 6, 2021
Comments: