A year in the modern Gregorian Calendar consists of 365 days. In reality, the earth takes longer to rotate around the sun. To account for the difference in time, every 4 years, a leap year takes...



I need help passing the unit test.




my code(python):


def is_leap_year(user_year):
    if user_year%400 == 0:
        return True
    elif user_year%100 != 0 and user_year%4 == 0:
        return True
    return False




year = int(input())
if is_leap_year(year):
    print(str(year) + " is a leap year.")
else:
    print(str(year) + " is not a leap year.")


A year in the modern Gregorian Calendar consists of 365 days. In reality, the earth takes longer to rotate around the sun. To account for the<br>difference in time, every 4 years, a leap year takes place. A leap year is when a year has 366 days: An extra day, February 29th. The<br>requirements for a given year to be a leap year are:<br>1) The year must be divisible by 4<br>2) If the year is a century year (1700, 1800, etc.), the year must be evenly divisible by 400<br>Some example leap years are 1600, 1712, and 2016.<br>Write a program that takes in a year and determines whether that year is a leap year.<br>Ex: If the input is:<br>1712<br>the output is:<br>1712 is a leap year.<br>Ex: If the input is:<br>913<br>the output is:<br>1913 is not a leap year.<br>Your program must define and call the following function. The function should return True if the input year is a leap year or False otherwise.<br>def is_leap_year(user_year)<br>

Extracted text: A year in the modern Gregorian Calendar consists of 365 days. In reality, the earth takes longer to rotate around the sun. To account for the difference in time, every 4 years, a leap year takes place. A leap year is when a year has 366 days: An extra day, February 29th. The requirements for a given year to be a leap year are: 1) The year must be divisible by 4 2) If the year is a century year (1700, 1800, etc.), the year must be evenly divisible by 400 Some example leap years are 1600, 1712, and 2016. Write a program that takes in a year and determines whether that year is a leap year. Ex: If the input is: 1712 the output is: 1712 is a leap year. Ex: If the input is: 913 the output is: 1913 is not a leap year. Your program must define and call the following function. The function should return True if the input year is a leap year or False otherwise. def is_leap_year(user_year)
1: Compare output a<br>2/2<br>Input<br>1712<br>Your output<br>1712 is a leap year.<br>2: Unit test ^<br>0/2<br>is_leap_year(1913)<br>3: Unit test ^<br>0/3<br>is_leap_year(1600)<br>4: Unit test ^<br>0/3<br>is_leap_year(1900)<br>

Extracted text: 1: Compare output a 2/2 Input 1712 Your output 1712 is a leap year. 2: Unit test ^ 0/2 is_leap_year(1913) 3: Unit test ^ 0/3 is_leap_year(1600) 4: Unit test ^ 0/3 is_leap_year(1900)

Jun 04, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here