――Isn't it an unpleasant student if I write this in paiza's coding skill check?
--The problem is in Coding sample on this page. ――The point is to judge the leap year.
――The conditions for leap year judgment are given as a reference, but the only problem is "Write a program to judge whether the entered integer is a leap year in the Gregorian calendar." ――The condition is divisible by 4, but as a result, February 29th exists in the "leap year", isn't it? ――Why is this answer?
import datetime
def leap(year):
try:
datetime.date(int(year), 2, 29)
return True
except Exception as inst:
return False
input_lines = int(input())
for i in range(input_lines):
year = input()
is_leap = ("is a leap" if leap(year) else "is not a leap")
print("{year} {is_leap} year".format(year=year, is_leap=is_leap))
――Of course there is an answer.
$ python leap.py < year.txt
1000 is not a leap year
1992 is a leap year
2000 is a leap year
2001 is not a leap year
――Maybe it's not straightforward, but what do you think about the hiring side?