Posts

Showing posts with the label Leap Year

Leap Year in Python

Year 2008 is a leap year. The leap year thing is always interesting. Sometimes I also think about the unfortunate people who have birthday on 29th February! :) Let me write two modules that determines whether a year is leap year or not, (I also write test module for this). def is_leap_year2(year):     if year % 400 == 0:         return True     elif year % 100 == 0:         return False     elif year % 4 == 0:         return True     else:     return False def is_leap_year(year):     if year % 100 != 0 and year % 4 == 0:         return True     elif year % 100 == 0 and year % 400 == 0:         return True     else:    ...