@author python.learning
>>> def check_year(year):
... if year%4==0 and year%100!=0 or year%400==0:
... print ('leap year')
... else:
print ('not a leap year')
>>> check_year(1972)
leap year
>>> check_year(1975)
not a leap year
# or check with calendar
>>> import calendar
>>> print (calendar.isleap(1972) )
True
>>> print (calendar.isleap(1975) )
False
>>> def check_year(year):
... if year%4==0 and year%100!=0 or year%400==0:
... print ('leap year')
... else:
print ('not a leap year')
>>> check_year(1972)
leap year
>>> check_year(1975)
not a leap year
# or check with calendar
>>> import calendar
>>> print (calendar.isleap(1972) )
True
>>> print (calendar.isleap(1975) )
False
0 Comments:
Post a Comment