Home  >  Article  >  Backend Development  >  How to find leap years from 2000 to 2500 using python programming?

How to find leap years from 2000 to 2500 using python programming?

coldplay.xixi
coldplay.xixiOriginal
2020-06-23 14:03:4013516browse

How to find leap years from 2000 to 2500 using python programming?

How to find leap years from 2000 to 2500 using python programming?

Python programming method to find leap years from 2000 to 2500:

First define the year [i=2000]; then use a while loop to determine whether it is within 2500; Then if the year is divisible by 40 and not divisible by 100, it is a leap year. If the year is divisible by 400, it is a leap year.

The specific code is as follows:

i=2000
j=0
while i<=2500:
if i%40 and i%100!=0 or i%4000:
print(i)
j+i
if j%10==0:
print
i+=1

How to find leap years from 2000 to 2500 using python programming?

Recommended tutorial: "python video tutorial"

The above is the detailed content of How to find leap years from 2000 to 2500 using python programming?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn