Question: Write an interactive Python program ( leapyear.py ) that given a year will decide if it is a leap year or not. Before tackling this
Write an interactive Python program (leapyear.py) that given a year will decide if it is a leap year or not. Before tackling this problem make sure you read and understand the following explanation:
In the Gregorian calendar, a normal year consists of 365 days. Because the actual length of a sidereal year (the time required for the Earth to revolve once about the Sun) is actually 365.25635 days, a "leap year" of 366 days is used once every four years to eliminate the error caused by three normal (but short) years. Any year that is evenly divisible by 4 is a leap year: for example, 1988, 1992, and 1996 are leap years.
However, there is still a small error that must be accounted for. To eliminate this error, the Gregorian
calendar stipulates that a year that is evenly divisible by 100 (for example, 1900) is a leap year only if it is also evenly divisible by 400.
Your program should take a year as input from the keyboard and print out if it is a leap year or not. File years.txt includes some test cases that you should test your program with. If your program is correctly implemented, the test cases in years.txt will prove it.
[Hint: You may need to use nested conditional statements and/or Boolean operations for multiple conditions checking.]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
