Last active
May 23, 2023 14:20
-
-
Save makoru-hikage/22120538b27a22b869cbfaca966f9abd to your computer and use it in GitHub Desktop.
A leap year is divisible by 4, not divisible by 100 only, and divisible by 400.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
def is_leap_year (n): | |
if n % 100 == 0: | |
dividedBy100 = n / 100 | |
if dividedBy100 % 4 == 0: | |
return True | |
else: | |
return n % 4 == 0 | |
# From 1900 to 2000 | |
a = [x + 1900 for x in range(101) if is_leap_year(x + 1900)] | |
print(len(a)) | |
print(a) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment