fork download
  1. # your code goes here
  2. # 题目4:闰年判断
  3. # 要求:判断输入的年份是否为闰年。
  4. # 闰年规则:能被4整除但不能被100整除,或者能被400整除。
  5. n = int(input('请输入年:'))
  6. if n%4==0 and n%100!=0 or n%400==0:
  7. print (str(n)+"年是闰年")
  8. else :
  9. print (str(n)+"年不是闰年")
Success #stdin #stdout 0.07s 14040KB
stdin
2022
stdout
请输入年:2022年不是闰年