Home > Backend Development > Python Tutorial > 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
Release: 2020-06-24 09:02:31
Original
13649 people have browsed it

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
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template