Last active
October 31, 2021 12:11
-
-
Save qiuyujx/fcacc476e9e494540e38326fdd3390f2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime | |
class Employee: | |
def __init__(self, name, year_joined): | |
self.name = name | |
self.year_joined = year_joined | |
def calc_year(self, year_joined, year_now): | |
length = year_now - year_joined | |
if length > 0: | |
return f'{length} years' | |
else: | |
return 'less than one year' | |
def seniority(self): | |
n_years = self.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