포스트

[Python] Baekjun number 2753 - leap year

We have summarized the solution that implements the leap year determination condition using Python's and/or conditional expression.

한국어 원문은 여기에서 볼 수 있습니다.
[Python] Baekjun number 2753 - leap year

BaekJoon 2753

Solution

1
2
3
4
5
6
7
8
year = int(input())

if year%4 == 0:
    if (year%100 != 0) or (year%400 == 0):
        print("1")
    else:
        print("0")
else: print("0")

In Python, unlike Java or C, you must use the || or && operators as or and and.