Python Program to display all leap years between 1900 to 2101
Firstly we needs to know that what is a leap year ?
A leap year is a year which has 366 days, which occuring onec in every 4 years, and which involves 29 days in february.
This explaination in right for the non IT or normal peoples.
But as point of view of an programmer, a leap year is a year which exactly divisible by 4 excepted centuary years ( years which ending with 00).
And the centuary year is a leap year when it is perfecly divisible by 400.
For Example,
2009 is not a leap year !
1900 is not a leap year !
1984 is a leap year !
2000 is a leap year !
Following is the program of Leap year which shows the logic of an Leap year.
Program to display Leap Years from 1900 to 2101:
This is the code that shows the actual program to display all the leap years from 1900 to 2101.
In that we have taken 2 variables (starting_year and Ending_year) to store the years ( 1900 and 2101).
After that, we have used a for loop to iterate our leap years logic from 1900 to 2101.
In that for loop, We have implemented our Logic to check the year is a leap year or not.
To print the year, we have used f-string, which passes the data stored in the varable given in curly brackets { }.
0 Comments
Please do not add Any Spam link in Comments !