artık yıl örneği 2

This commit is contained in:
Mert Gör ☭ 2023-08-03 23:25:09 +03:00
parent bcf2574136
commit bef5decfb9
No known key found for this signature in database
GPG Key ID: 2100A876D55B39B9
2 changed files with 44 additions and 0 deletions

View File

@ -0,0 +1,22 @@
class Date:
def __init__(self, day, month, year):
self.day = day
self.month = month
self.year = year
def disp(self):
print('{}/{}/{}'.format(self.day, self.month, self.year))
@staticmethod
def isLeapYear(year):
return year % 400 == 0 or year % 4 == 0 and year % 100 != 0
date = Date(10, 12, 2007)
date.disp() # örnek metodun çağrılması için asıl biçim
Date.disp(date) # örnek metodun çağrılması için alternatif biçim
result = Date.isLeapYear(2000) # static metodun çağrılması için asıl biçim
print('Artık' if result else 'Artık değil')
result = date.isLeapYear(2000) # static metodun çağrılması için alternatif biçim
print('Artık' if result else 'Artık değil')

View File

@ -0,0 +1,22 @@
class Date:
def __init__(self, day, month, year):
self.day = day
self.month = month
self.year = year
def disp(self):
print('{}/{}/{}'.format(self.day, self.month, self.year))
@staticmethod
def isLeapYear(year):
return year % 400 == 0 or year % 4 == 0 and year % 100 != 0
date = Date(10, 12, 2007)
date.disp() # örnek metodun çağrılması için asıl biçim
Date.disp(date) # örnek metodun çağrılması için alternatif biçim
result = Date.isLeapYear(2000) # static metodun çağrılması için asıl biçim
print('Artık' if result else 'Artık değil')
result = date.isLeapYear(2000) # static metodun çağrılması için alternatif biçim
print('Artık' if result else 'Artık değil')