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
- Create a function leap.
- Use the def keyword to define the function.
- Pass a parameter i.e. year.
- 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.
- Print the respective output.
- 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
Python function program to reverse an integer.
Python function program to create a library management system.
Python function program to add two Binary numbers.
Python function program to search words in a string.
Python function program to get the length of the last word in a string.
Python function program to get a valid mobile number.