Header Ads Widget

Python program to check whether a year is leap year or not

  

 Python program to check whether a year is leap year or not

Given a year , write a program to check whether it is leap year or not . So first we have to know that what is leap year .

Leap year : - 
  • A leap year is a calendar year that contains an additional day added to keep the calendar year synchronized with the astronomical year or seasonal year
  • Generally Year which is divided by 4 is know as leap year . but the year which are divided by 100 for these year we have to check that whether it is divided by 400 or not . if it is then the year is leap year .
Sample input :
2001
Sample output:
2001 is not a leap year 

 Python program to check whether a year is leap year or not

The objective of the code is to check that the year is leap year or not .

Code(Python):-

year=int(input())
if year%100==0:
if year%400==0:
print(f"{year} is a leap year")
else:
print(f"{year} is not a leap year")
elif year%4==0:
print(f"{year} is a leap year")
else:
print(f"{year} is not a leap year")


Output:-

1600
1600 is a leap year



Recommended Post :-

HCL Coding Questions:-

Capgemini Coding Questions:-

Companies interview:-

Full C course:-    

Key points:-

Cracking the coding interview:-

 Array and string:-

Tree and graph:-

Hackerearth Problems:-

Hackerrank Problems:-

Data structure:-

 MCQs:-

Post a Comment

0 Comments