Program to check whether the given year is a leap year

In this python function program, we will create a function to check whether the given year is a leap year.


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.

What is Function?
It is a block of code that executes when it is called.
To create a function use def keyword.

Steps to solve the program
  1. Create a function leap.
  2. Use the def keyword to define the function.
  3. Pass a parameter i.e. year.
  4. Use the following condition to check whether the given year is a leap year or not – (year%400 == 0 or year%100 != 0) and year%4 == 0.
  5. Print the respective output.
  6. Pass the year to the function while calling the function.
				
					def leap(a):
    if (a%100!=0 or a%400==0) and a%4==0:
        print("The given year is leap year.")
    else:
        print("The given year is not leap year.")
leap(2005)
				
			

Output :

				
					The given year is not leap year.
				
			

Related Articles

create a Fruitshop Management system.

program to reverse an integer.

Leave a Comment