Skip to content

Instantly share code, notes, and snippets.

@qiuyujx
Last active October 31, 2021 12:12
Show Gist options
  • Save qiuyujx/e72ab14cbe9096439322b286a38991b4 to your computer and use it in GitHub Desktop.
Save qiuyujx/e72ab14cbe9096439322b286a38991b4 to your computer and use it in GitHub Desktop.
def calc_year(year_joined, year_now):
length = year_now - year_joined
if length > 0:
return f'{length} years'
else:
return 'less than one year'
class Employee:
def __init__(self, name, year_joined):
self.name = name
self.year_joined = year_joined
def seniority(self):
n_years = calc_year(self.year_joined, datetime.now().year)
print(f'{self.name} has worked in our company for {n_years}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment