Program to check leap year or not in python
Example: 2000,2012 etc.,
Program:
/*Python program to check the given number is a leap year or not*/
def check_Year(yr): if (yr % 4) == 0: if (yr % 100) == 0: if (yr % 400) == 0: return True else: return False else: return True else: return False yr = 2000 if(check_Year(yr)): print("It is a Leap Year") else: print("It is not a Leap Year")
Output:
It is a Leap year
def is a keyword used to define user-defined functions, here check_Year(yr) is the user defined
function which is used to check the given number is leap year or not ,if it is a leap year returns
True else returns False. If it returns True then the output will be 'It is a Leap Year else the output
will be It is not a Leap year.
True else returns False. If it returns True then the output will be 'It is a Leap Year else the output
will be It is not a Leap year.

0 Comments