Q. Python Program to Check Whether the Given Year is Leap Year or Not.
Here you will find an algorithm and program in C programming language to check whether the given year is leap year or not. First let us understand what is leap year?
Explanation : A leap year is a calendar year that contains an additional day added to keep the calendar year synchronized. A leap year is exactly divisible by 4, except for the century years (the years ending with 00). Century year is a leap year only if it is completely divisible by 400.
For Example : 2012 is Leap Year, 2014 is not a leap year.
Leap Year Algorithm
START Step 1 → Initialize variable year Step 3 → Check if year is divisible by 4 but not by 100, DISPLAY "leap year" Step 4 → Check if year is divisible by 400, DISPLAY "leap year" Step 5 → Otherwise, DISPLAY "not leap year" STOP
Python Program to Check Leap Year
check_year = 1998 if (check_year % 4) == 0: if (check_year % 100) == 0: if (check_year % 400) == 0: print("{0} is a leap year".format(check_year)) else: print("{0} is not a leap year".format(check_year)) else: print("{0} is a leap year".format(check_year)) else: print("{0} is not a leap year".format(check_year))
Output
1998 is not a leap year.