Last active
April 4, 2022 22:02
-
-
Save codewithkevin/0c01a8ab656798f6c4cf3699a0ff98f9 to your computer and use it in GitHub Desktop.
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
#For a year to be a leap year, it must be divisible by 4, | |
# unless it is also divisible by 100. However, | |
# it cannot be a leap year if it is divisible by 400. | |
year = int(input("Enter a year: ")) | |
if year % 4 == 0: | |
if year % 100 == 0: | |
if year % 400 == 0: | |
print(f"{year} is a leap year") | |
else: | |
print(f"{year} is not a leap year") | |
else: | |
print(f"{year} is a leap year") | |
else: | |
print(f"{year} is not a leap year") | |
OR | |
if year % 4 == 0 and year % 100 == 0 and year % 400 == 0: | |
print(f"{year} is a leap year") | |
else: | |
print(f"{year} is not a leap year") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
done