程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

[Python] learning notes week8-1 leap year judgment

編輯:Python

【PYTHON】 Judge leap year branch

Title Description

Judge whether a year is a leap year .

Input

There is only one line of input , Contains an integer a

Output

a line , If A.D a A year is a leap year Y, Otherwise output N

The sample input

2006

Sample output

N

Tips

In the Gregorian calendar , Can be 4 Most of them are leap years , But it can be 100 Divide without being 400 Divisible years are not leap years , Can be 3200 It's not a leap year , Such as 1900 Year is a normal year ,2000 Year is a leap year ,3200 Year is not a leap year .

a=eval(input())
if a%4!=0:
print("N")
elif a%4==0:
if a%100==0 and a%400!=0:
print("N")
elif a%3200==0:
print("N")
else:
print("Y")

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved