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

Blue Bridge Cup practice system judge leap year (Python)

編輯:Python

Problem description

Given a year , Judge whether this year is a leap year .
When one of the following conditions is satisfied , This year is a leap year :

  1. The year is 4 Instead of 100 Multiple ;
  2. The year is 400 Multiple .
    Other years are not leap years .

Input format

Input contains an integer y, Represents the current year .

Output format

Output one line , If a given year is a leap year , The output yes, Otherwise output no.
explain : When the question specifies that you output a string as the result ( For example, this topic yes perhaps no, You need to strictly follow the case given in the test , Wrong case will not score .

Reference code

n = int(input())
if n % 4 == 0 and n % 100 != 0:
print("yes")
elif n % 400 == 0:
print("yes")
else:
print("no")

Investigate knowledge points

I don't seem to have any knowledge , If you have not understand , Welcome to ask questions in the comment area


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