Leap Year Determination

  • Share this:

Code introduction


Determines whether a given year is a leap year. A leap year is a year that is divisible by 4 but not by 100, or is divisible by 400.


Technology Stack : math, re, datetime, sys, random, os, json, shutil

Code Type : Function

Code Difficulty : Intermediate


                
                    
import math
import re
import datetime
import sys
import random
import os
import json
import shutil

def is_leap_year(year):
    """
    判断是否为闰年
    """
    return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0)