[Tutor] How to test for a remainder from division
John Fouhy
john at fouhy.net
Tue May 15 00:17:35 CEST 2007
On 15/05/07, Arthur Coleman <arthur at nowsol.com> wrote:
> Hi,
>
> I believe it should be if !(year % 4) or !(year % 100) or !(year % 400)
FWIW, the correct leapyear test is:
if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0):
# then year is a leap year
Year 2100 will not be a leap year, despite being divisible by 4. But
y2k was a leap year, because it was a multiple of 400.
--
John.
More information about the Tutor
mailing list