This is a Python Program to check whether a given year is a leap year or not.
The program takes in a year and checks whether it is a leap year or not.
1. Take the value of the year as input
2. Using an if-statement, check whether the year is a leap year or not
3. Print the final result
Here is source code of the Python Program to Calculate the Average of Numbers in a Given List. The program output is also shown below.
year=int(input("Enter year to be checked:")) if(year%4==0 and year%100!=0 or year%400==0): print("The year is a leap year!) else: print("The year isn't a leap year!)
1. User must first enter the year to be checked.
2. The if statement checks if the year is a multiple of 4 but isn’t a multiple of 100 or if it is a multiple of 400 (not every year that is a multiple of 4 is a leap year).
3. Then the result is printed.
Case 1: Enter year to be checked:2016 The year is a leap year! Case 2: Enter year to be checked:2005 The year isn't a leap year!
Sanfoundry Global Education & Learning Series – Python Programs.
To practice all Python programs, here is complete set of 150+ Python Problems and Solutions.