766 · 闰年

描述
判断给出的年份 n 是否为闰年. 如果 n 为闰年则返回 true

闰年是包含额外一天的日历年. 如果年份可以被 4 整除且不能被 100 整除 或者 可以被 400 整除, 那么这一年为闰年. --wikipedia

样例
样例 1:

输入 : n = 2008
输出 : true
样例 2:

输入 : n = 2018
输出 : false

class Solution:
    """
    @param n: a number represent year
    @return: whether year n is a leap year.
    """
    def isLeapYear(self, n):
        return n%400==0 or (n%100!=0 and n%4==0)
posted @ 2021-04-08 20:48  bernieloveslife  阅读(41)  评论(0编辑  收藏  举报