Skip to content

Commit 504b76f

Browse files
imaryankrtechyminati
authored andcommitted
Create leapyear.py
1 parent 2ea1196 commit 504b76f

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

‎leapyear.py‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Python program to check if year is a leap year or not
2+
3+
year = 2000
4+
5+
# To get year (integer input) from the user
6+
# year = int(input("Enter a year: "))
7+
8+
# divided by 100 means century year (ending with 00)
9+
# century year divided by 400 is leap year
10+
if (year % 400 == 0) and (year % 100 == 0):
11+
print("{0} is a leap year".format(year))
12+
13+
# not divided by 100 means not a century year
14+
# year divided by 4 is a leap year
15+
elif (year % 4 ==0) and (year % 100 != 0):
16+
print("{0} is a leap year".format(year))
17+
18+
# if not divided by both 400 (century year) and 4 (not century year)
19+
# year is not leap year
20+
else:
21+
print("{0} is not a leap year".format(year))

0 commit comments

Comments
 (0)