Home > Backend Development > Python Tutorial > Python determines leap year

Python determines leap year

巴扎黑
Release: 2016-12-08 10:14:42
Original
3685 people have browsed it

#-*- coding:utf-8 -*-
try:
  year = int(raw_input('请输入年份(如2008): '))
except:
  print '请输入正确的年份'
  exit()
is_leap = False
if year % 100 == 0 and year % 400 == 0:
  is_leap = True
elif year % 100 != 0 and year % 4 == 0:
  is_leap = True
if is_leap:
  print '%d年是闰年!' % year
else:
  print '%d年不是闰年!' % year
Copy after login

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