0 votes
116 views
in Python by (98.9k points)
edited
Python Program to Check Leap Year

1 Answer

0 votes
by (98.9k points)
selected by
 
Best answer
year = int(input("Enter a year: "))

# divided by 100 means century year (ending with 00)
# century year divided by 400 is leap year
if (year % 400 == 0) and (year % 100 == 0):
    print("{0} is a leap year".format(year))

# not divided by 100 means not a century year
# year divided by 4 is a leap year
elif (year % 4 ==0) and (year % 100 != 0):
    print("{0} is a leap year".format(year))

# if not divided by both 400 (century year) and 4 (not century year)
# year is not leap year
else:
    print("{0} is not a leap year".format(year))

 

Related questions

0 votes
1 answer 149 views
asked Jul 20, 2022 in C programming by Doubtly (98.9k points)
0 votes
1 answer 183 views
asked Jun 11, 2022 in Python by Doubtly (98.9k points)
0 votes
1 answer 193 views
0 votes
1 answer 284 views

Doubtly is an online community for engineering students, offering:

  • Free viva questions PDFs
  • Previous year question papers (PYQs)
  • Academic doubt solutions
  • Expert-guided solutions

Get the pro version for free by logging in!

5.7k questions

5.1k answers

108 comments

561 users

...