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 tokiojapan55
import datetime
class Person:
def __init__(self, first_name, last_name, birth_date, job, working_years, salary, country, city, gender='unknown'):
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):
today = datetime.datetime.strptime('01.01.2018', '%d.%m.%Y').date()
birthday = datetime.datetime.strptime(self.birth_date, '%d.%m.%Y').date()
age = today.year - birthday.year
if today.month < birthday.month or (today.month == birthday.month and today.day < birthday.day):
age -= 1
return age
def work(self):
pronown = {'male':'He is', 'female':'She is', 'unknown':'Is'}
return f'{pronown[self.gender]} a {self.job}'
def money(self):
return '{:,}'.format(self.salary*self.working_years*12).replace(',', ' ')
def home(self):
return f'Lives in {self.city}, {self.country}'
June 12, 2020
Comments: