leapyear_t_f.py
from calendar import isleap
for y in range(1582,2001):
y4=(y % 4) == 0
y100=y % 100 != 0
y400=y % 400 == 0
if y4 and (y100 or y400):
print(y,'is leap.\t','isleap=',isleap(y),end='')
print('\tBoolean =',y4,'and',y100,'or',y400)
else:
print(y,'is common.\t','isleap=',isleap(y),end='')
print('\tBoolean =',y4,'and',y100,'or',y400)
leapyear.py
from calendar import isleap
#y = 1582
for y in range(1031,2001):
if ((y % 4) == 0 and (y % 100 != 0 or y % 400 == 0)):
print(y,'is leap.\t',isleap(y))
else:
print(y,'is common.\t',isleap(y))
ความคิดเห็น
แสดงความคิดเห็น