0
Leap Year
Hi all, I would like to have a clarification in the Python "Leap Year" challenge for beginners. Although I have seen how to do it, I have not understood why it is done this way, i.e. what is the use of 4, 100, and 400 as numbers that I have to use to make a difference?
3 Respuestas
+ 2
Each year, as the Earth goes around the Sun and returns to the same location, it takes an extra 0.2425 days to get there.
Every 4 years that adds up to almost 1 full day extra (4x0.2425 = 0.97) so we add a day to the year.
Every 100 years the above rule would add 25 days, but that's 1 too many (100x0.2425 = 24.25) so we skip a leap year.
Every 400 years the above two rules would add 96 days, but that is 1 day too short (400x0.2425 = 97), so we add a day.
+ 1
The numbers 4, 100, 400 refer to the task description.
Please link the code that you would like us to explain.
0
That's a logic to find leap year.
Leap year is evenly divisible 4 but not divisible by 100 at the same time Or divisible by 400 at the same time. (some thing similar.)
Other year are not met these conditions.