In this python, if else program, we will check whether a given year is a leap or not.
Leap Year: A year, occurring once every four years, which has 366 days including 29 February as an intercalary day. A Century year is a leap year only if it is perfectly divisible by 400.
Steps to solve the program
- Take a year as input through the user.
- Use the following conditions to check whether a year is a leap or not. a)year%100 != 0 or year%400 == 0, b) year%4 == 0.
- Use an if-else statement for this purpose.
- Print the output.
year = int(input("Enter the year: "))
if (year%100 != 0 or year%400 == 0) and year%4 == 0:
print("The given year is leap year.")
else:
print("The given year is not leap year.")
Output :
Enter the year: 2000
The given year is leap year.
Related Articles
Python program to check whether an alphabet is a vowel.
Python program to check whether an alphabet is a consonant.
Python program to convert the month name to the number of days.
Python program to check whether a triangle is equilateral or not.
Python program to check whether a triangle is scalene or not.