A year is a Leap year if it is divisible by 4, unless it is a century year that is not divisible by 400 (1800 and 1900 are not leap years, 1600 and 2000 are leap years). Write a program that calculates whether a given year is a leap year or not.
A year is a Leap year if it is divisible by 4, unless it is a century year that is not divisible by 400 (1800 and 1900 are not leap years, 1600 and 2000 are leap years). Write a program that calculates whether a given year is a leap year or not.
A leap year is a year that contains an additional day added to keep the calendar year synchronized with the astronomical year or seasonal year. A year is a leap year if it is divisible by 4, unless it is a century year that is not divisible by 400 (1800 and 1900 are not leap years, 1600 and 2000 are leap years). In this blog post, we will discuss how to write a Python program that calculates whether a given year is a leap year or not.
Table of Contents:
- What is a leap year?
- Problem Statement
- Solution
- Explanation of Program Code
- MCQs with Answers
What is a leap year?
As mentioned earlier, a leap year is a year that has one extra day, 366 days instead of the usual 365 days. This extra day is added to keep our calendar in sync with the Earth’s orbit around the sun. Without leap years, our calendar would drift away from the actual seasons over time, leading to significant errors in our seasonal and astronomical events.
Problem Statement:
Write a Python program that calculates whether a given year is a leap year or not.
Solution:
To solve this problem, we can use the following algorithm:
- Get the year from the user.
- Check if the year is divisible by 4.
- If the year is divisible by 4, check if it is a century year.
- If the year is a century year, check if it is divisible by 400.
- If the year is divisible by 400, it is a leap year.
- If the year is not divisible by 400, it is not a leap year.
- If the year is not divisible by 4, it is not a leap year.
https://www.computerbitsdaily.com/2023/05/python-program-to-check-leap-year.html