Question: class TimeType: def _ _ init _ _ ( self , hr = 0 , min = 0 , sec = 0 ) : self.hr
class TimeType:
def initself hr min sec:
self.hr hr
self.min min
self.sec sec
class ClockTimeType:
monthdays
def initself:
superinit
self.month
self.day
self.year
@classmethod
def leapyearcls year:
if year :
return True
elif year :
return False
elif year :
return True
else:
return False
def setclockself hrs mins, secs mon, dy yr:
if mon or mon :
return False
if dy or dy self.monthdaysmon :
return False
if mon and dy and not self.leapyearyr:
return False
self.hr hrs
self.min mins
self.sec secs
self.month mon
self.day dy
self.year yr
return True
def increasedayself:
if self.day self.monthdaysselfmonth :
self.day
else:
self.day
if self.month :
self.month
else:
self.month
self.year
if self.leapyearselfyear:
self.monthdays
else:
self.monthdays
def decreasedayself:
if self.day :
self.day
else:
if self.month :
self.month
self.day self.monthdaysselfmonth
else:
self.year
self.month
self.day
def increasesecondself:
self.sec
if self.sec :
self.sec
self.min
if self.min :
self.min
self.hr
if self.hr :
self.hr
self.increaseday
def decreasesecondself:
self.sec
if self.sec :
self.sec
self.min
if self.min :
self.min
self.hr
if self.hr :
self.hr
self.decreaseday
def strself:
ampm AM if self.hr else PM
hour self.hr if self.hr else self.hr
if hour :
hour
return fselfmonthselfdayselfyearhour:d:selfmin:d:selfsec:dampm
# Test client
clock Clock
printclock # Should print :: AM
clock.setclock
printclock # Should print :: PM
clock.increasesecond
printclock # Should print :: AMleap year
clock.decreasesecond
printclock # Should print :: PMleap year
my code is not printing leap year, how can I fix that
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
