Python program to check a year is leap or not | Python programming | Ask The Code
Problem:
Given a year, determine whether it is a leap year. If it is a leap year, return the Boolean True, otherwise return False. Note that the code stub provided reads from STDIN and passes arguments to the is leap function. It is only necessary to complete the is leap function.
Input:
Read year, the year to test.
Output:
The function must return a Boolean value (True/False). Output is handled by the provided code stub.
Sample input:
1990
Sample output:
False
Code:
def is_leap(year):
leap = False
if (year % 4 == 0 and year % 100 != 0) or year % 400 == 0:
leap = True
return leap
year = int(input())
print(is_leap(year))
コメント