In this blog, we are going to see a year is a leap year or not in python programming. Python Program to Check Leap Year.
What is a Leap Year?
As we know, a normal year has 365 days total. but in a leap year, there have 366 days(the extra day is the 29th of February).
Ex:- 2000, 2004, 2008, 2012, 2016, 2020, 2024, etc.
Key Points:-
- Leap Years are any year that can be exactly divided by 4, but not by 100 such as:-2016, 2024, etc).
- And Also any year that can be exactly divided by 400 and 100, then it is such as- 2000, 2400).
Keep in mind:- Remainder should be zero.
code:-
// input_year is a input that will be taken by user.
input_year=int(input("Enter year to be checked : "))
if input_year%4==0 and input_year%100!=0 or input_year%400==0):
print("The year is a Leap Year")
else:
print("The year is not a Leap Year")
Output:-
Enter year to be checked : 2012
The year is a Leap Year
Click Here to Download This Code.
Conclusion:
Now you can check whether a year is a leap year or not.
You should also check out, Django Developer Roadmap, Python Developer Roadmap, C++ Complete Roadmap, Machine Learning Complete Roadmap, Data Scientist Learning Roadmap, R Developer Roadmap, DevOps Learning Roadmap, and Laravel Developer Roadmap.
Thank you for reading this blog. I wish you the best in your journey to learning and mastering Python.
Follow me to receive more useful content:
Instagram | Twitter | Linkedin | Youtube
Thank you