Read the question, write Python on the right, then Run or Check.
QuestionHint and solution stay closed until you open them
Read a year and print yes if it is a leap year, otherwise no.
A year is a leap year if it is divisible by 4, except centuries (divisible by 100) which must also be divisible by 400.
Input. One line: an integer year.
Output. yes or no (lowercase).
Constraints
- 1 ≤ year ≤ 9999
Examples
Input
2000
Output
yes
Input
1900
Output
no
Input
2024
Output
yes
Hint
- year % 400 == 0 is always a leap year.
- Otherwise year % 4 == 0 and year % 100 != 0.
Show correct code
Peek only after you have tried. You can still Check your own version.
year = int(input())
leap = year % 400 == 0 or (year % 4 == 0 and year % 100 != 0)
print("yes" if leap else "no")
main.pyPython · Ctrl + Enter runs
ResultIdle
Run to see output. Check grades the tests.