Sort by

recency

|

2932 Discussions

|

  • + 0 comments

    def is_leap(year): leap = False if 1900 <= year <= 10**5: if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0): leap = True return leap year = int(input()) print(is_leap(year))

  • + 0 comments

    def is_leap(year): leap=True if year%100!=0: if year%4==0: leap=True else: leap=False elif year%100==0: if year%400==0: leap=True else: leap=False
    else: leap=False

    return leap
    
  • + 0 comments

    def is_leap(year):

    if year % 4 == 0 and year % 100 == 0 and year % 400 == 0:
        return True
    elif year % 4 == 0 and year % 100 == 0 and year % 400 != 0:
        return False
    elif year % 4 == 0 and year % 100 != 0:
        return True
    else:
        return False 
    
                kind of hard to get your head around what its asking. im a noob so theres probably a more simple code to get the answer, but this is easy to follow with human logic
    

    year = int(input()) print(is_leap(year))

  • + 0 comments

    It’s a tricky question to answer. We have three main conditions for leap years: * If the year is evenly divisible by 4, it is a leap year, unless: (year % 4 == 0) * If the year is evenly divisible by 100, it is NOT a leap year, unless: (year % 100 != 0) * However, if the year is also evenly divisible by 400, then it is a leap year: (year % 400 == 0)

    To determine if a year is a leap year, conditions 1 and 2 must both evaluate to True or False. Otherwise, compare condition 3 (year % 400 == 0) directly.

  • + 0 comments

    def is_leap(year): if (year%4==0 and year%100!=0) or year%400==0: return True else: return False

    year = int(input()) print(is_leap(year))